Created
March 2, 2016 12:46
-
-
Save ak1211/61db9759de4b04d0a033 to your computer and use it in GitHub Desktop.
ログのメッセージフィールドから必要な値をとる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def extract_start_session_from_log(line): | |
sep = line.rstrip().split (': ') | |
result = {} | |
result["terminate log"] = None | |
result["line"] = line | |
# | |
result["Message"] = sep[2] | |
result["Class"] = sep[1] | |
result["DateTime"] = toDateTime (sep[0]) | |
# | |
matches = re.match (r'Group <(.*?)> User <(.*?)> IP <(.*?)>', sep[2]) | |
result["Group"] = matches.group(1) | |
result["User"] = matches.group(2) | |
result["IP"] = matches.group(3) | |
return result | |
def extract_terminate_session_from_log(line): | |
sep = line.rstrip().split (': ') | |
result = {} | |
result["start log"] = None | |
result["line"] = line | |
# | |
result["Message"] = ': '.join (sep[2:]) | |
result["Class"] = sep[1] | |
result["DateTime"] = toDateTime (sep[0]) | |
# | |
matches = re.match (r'Group = (.*?), Username = (.*?), IP = (.*?), Session disconnected\. Session Type: (.*?), Duration: (.*?), ', result["Message"]) | |
result["Group"] = matches.group(1) | |
result["User"] = matches.group(2) | |
result["IP"] = matches.group(3) | |
result["SessionType"] = matches.group(4) | |
result["Duration"] = matches.group(5) | |
return result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment