Skip to content

Commit

Permalink
fix: [parser] multilinelog timezone fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cvandeplas committed Jun 12, 2024
1 parent 8f9d491 commit 657e5b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions tests/test_multilinelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_multilinelog_plist(self):
'''
expected_result = {
'timestamp': 1684925884000000,
'timestamp': 1684933084000000,
'datetime': '2023-05-24T12:58:04+00:00',
'loglevel': 'debug',
'hexID': '0x16bf9b000',
Expand Down Expand Up @@ -62,7 +62,7 @@ def test_multilinelog_curlybrackets(self):
} (Error Domain=MCMErrorDomain Code=29 "Invalid metadata-URLs should match: /private/var/mobile/Containers/Data/Application/0984009B-81D1-4F7F-BDBD-261E22059155 : /private/var/mobile/Containers/Data/VPNPlugin/0984009B-81D1-4F7F-BDBD-261E22059155" UserInfo={SourceFileLine=370, NSLocalizedDescription=Invalid metadata-URLs should match: /private/var/mobile/Containers/Data/Application/0984009B-81D1-4F7F-BDBD-261E22059155 : /private/var/mobile/Containers/Data/VPNPlugin/0984009B-81D1-4F7F-BDBD-261E22059155, FunctionName=+[MCMMetadata _readAndValidateMetadataInDictionary:containerURL:forUserIdentity:containerClass:checkClassPath:fsNode:transient:error:]})
'''
expected_result = {
'timestamp': 1684926336000000,
'timestamp': 1684933536000000,
'datetime': '2023-05-24T13:05:36+00:00',
'loglevel': 'err',
'hexID': '0x16be43000',
Expand All @@ -73,7 +73,7 @@ def test_multilinelog_curlybrackets(self):
def test_multilinelog_simple_1(self):
s = '''Wed May 24 12:55:37 2023 [72] <notice> (0x16afb3000) -[MCMClientConnection _regenerateAllSystemContainerPaths]: Rolling system container directory UUIDs on disk'''
expected_result = {
'timestamp': 1684925737000000,
'timestamp': 1684932937000000,
'datetime': '2023-05-24T12:55:37+00:00',
'loglevel': 'notice',
'hexID': '0x16afb3000',
Expand All @@ -85,7 +85,7 @@ def test_multilinelog_simple_1(self):
def test_mutlinelog_simple_2(self):
s = '''Wed May 24 13:05:30 2023 [72] <notice> (0x16be43000) _containermanagerd_init_block_invoke: containermanagerd first boot cleanup complete'''
expected_result = {
'timestamp': 1684926330000000,
'timestamp': 1684933530000000,
'datetime': '2023-05-24T13:05:30+00:00',
'loglevel': 'notice',
'hexID': '0x16be43000',
Expand All @@ -97,13 +97,13 @@ def test_multilinelog_simple_multiplelines(self):
s = '''Wed May 24 13:05:30 2023 [72] <notice> (0x16be43000) _containermanagerd_init_block_invoke: containermanagerd first boot cleanup complete
Wed May 24 12:55:37 2023 [72] <notice> (0x16afb3000) -[MCMClientConnection _regenerateAllSystemContainerPaths]: Rolling system container directory UUIDs on disk'''
expected_result_0 = {
'timestamp': 1684926330000000,
'timestamp': 1684933530000000,
'datetime': '2023-05-24T13:05:30+00:00',
'loglevel': 'notice',
'hexID': '0x16be43000',
'msg': '_containermanagerd_init_block_invoke: containermanagerd first boot cleanup complete'}
expected_result_1 = {
'timestamp': 1684925737000000,
'timestamp': 1684932937000000,
'datetime': '2023-05-24T12:55:37+00:00',
'loglevel': 'notice',
'hexID': '0x16afb3000',
Expand Down Expand Up @@ -138,14 +138,14 @@ def test_multilinelog_keyvalue(self):
Wed May 24 13:08:13 2023 [135] <debug> (0x16f1db000) MA: main: soc_generation: H9
Wed May 24 13:08:13 2023 [135] <debug> (0x16f1db000) MA: main: ____________________________________________________________________'''
expected_result_0 = {
'timestamp': 1684925737000000,
'timestamp': 1684932937000000,
'datetime': '2023-05-24T12:55:37+00:00',
'loglevel': 'notice',
'hexID': '0x16afb3000',
'event_type': 'MCMClientConnection _regenerateAllSystemContainerPaths',
'msg': 'Rolling system container directory UUIDs on disk'}
expected_result_1 = {
'timestamp': 1684926493000000,
'timestamp': 1684933693000000,
'datetime': '2023-05-24T13:08:13+00:00',
'loglevel': 'debug',
'hexID': '0x16f1db000',
Expand Down Expand Up @@ -173,13 +173,13 @@ def test_multilinelog_keyvalue_onlyend(self):
s = '''Sat Feb 18 09:48:38 2023 [2695] <debug> (0x16dc37000) MA: main: ____________________________________________________________________
Sat Feb 18 09:48:39 2023 [2695] <debug> (0x16dc37000) MA: dealwith_activation: Activation State: Activated'''
expected_result_0 = {
'timestamp': 1676710118000000,
'timestamp': 1676713718000000,
'datetime': '2023-02-18T09:48:38+00:00',
'loglevel': 'debug',
'hexID': '0x16dc37000',
'msg': 'MA: main: ____________________________________________________________________'}
expected_result_1 = {
'timestamp': 1676710119000000,
'timestamp': 1676713719000000,
'datetime': '2023-02-18T09:48:39+00:00',
'loglevel': 'debug',
'hexID': '0x16dc37000',
Expand All @@ -191,7 +191,7 @@ def test_multilinelog_keyvalue_onlyend(self):
def test_multilinelog_keyvalue_onlystart(self):
s = '''Fri Dec 2 11:32:19 2022 [84816] <debug> (0x16afff000) MA: main: ____________________ Mobile Activation Startup _____________________'''
expected_result = {
'timestamp': 1669977139000000,
'timestamp': 1669980739000000,
'datetime': '2022-12-02T11:32:19+00:00',
'loglevel': 'debug',
'hexID': '0x16afff000',
Expand Down
2 changes: 1 addition & 1 deletion utils/multilinelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def build_from_logentry(line):
weekday, month, day, time, year = (str.split(timestamp[:24]))
day = day_converter(day)
month = month_converter(month)
timestamp = datetime.strptime(f"{year}-{month}-{day} {time}", "%Y-%m-%d %H:%M:%S")
timestamp = datetime.fromisoformat(f"{year}-{month}-{day}T{time}Z")
entry['timestamp'] = int(timestamp.timestamp() * 1000000)
entry['datetime'] = timestamp.strftime("%Y-%m-%dT%H:%M:%S+00:00")

Expand Down

0 comments on commit 657e5b6

Please sign in to comment.