From e8072851d590ff5cc9dff80104506f7948a58e76 Mon Sep 17 00:00:00 2001 From: Thilo Molitor Date: Sun, 1 Oct 2023 05:44:32 +0200 Subject: [PATCH] Don't preformat loglines, we fully use structured logging now This reduces the logfile size significantly nearly cutting it into halves. --- Monal/Classes/HelperTools.h | 3 +- Monal/Classes/HelperTools.m | 60 ++++++++++++++--------- Monal/Classes/MLConstants.h | 1 - Monal/Classes/MLFileLogger.m | 2 +- Monal/Classes/MLLogFormatter.h | 19 -------- Monal/Classes/MLLogFormatter.m | 70 --------------------------- Monal/Classes/MLUDPLogger.m | 5 +- Monal/Monal.xcodeproj/project.pbxproj | 8 --- UDPLogServer/server.py | 43 ++++++++++++---- 9 files changed, 73 insertions(+), 138 deletions(-) delete mode 100755 Monal/Classes/MLLogFormatter.h delete mode 100755 Monal/Classes/MLLogFormatter.m diff --git a/Monal/Classes/HelperTools.h b/Monal/Classes/HelperTools.h index b203d67b08..15e7daac85 100644 --- a/Monal/Classes/HelperTools.h +++ b/Monal/Classes/HelperTools.h @@ -27,7 +27,6 @@ NS_ASSUME_NONNULL_BEGIN @class xmpp; @class XMPPStanza; @class UNNotificationRequest; -@class DDLogFormatter; @class DDLogMessage; @class MLFileLogger; @class UIView; @@ -40,7 +39,7 @@ void swizzle(Class c, SEL orig, SEL new); @property (class, nonatomic, strong) MLFileLogger* fileLogger; -+(NSData* _Nullable) convertLogmessageToJsonData:(DDLogMessage*) logMessage usingFormatter:(id _Nullable) formatter counter:(uint64_t*) counter andError:(NSError** _Nullable) error; ++(NSData* _Nullable) convertLogmessageToJsonData:(DDLogMessage*) logMessage counter:(uint64_t*) counter andError:(NSError** _Nullable) error; +(void) initSystem; +(void) installExceptionHandler; +(int) pendingCrashreportCount; diff --git a/Monal/Classes/HelperTools.m b/Monal/Classes/HelperTools.m index b31f9bb6c4..92408a782e 100644 --- a/Monal/Classes/HelperTools.m +++ b/Monal/Classes/HelperTools.m @@ -15,6 +15,7 @@ #include #include #include +#import #import #import #import @@ -1374,11 +1375,10 @@ +(void) activityLog if(log_activity) { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ - BOOL appex = [HelperTools isAppExtension]; unsigned long counter = 1; while(counter++) { - DDLogInfo(@"activity(%@): %lu, memory used / available: %.3fMiB / %.3fMiB", appex ? @"APPEX" : @"MAINAPP", counter, [self report_memory], (CGFloat)os_proc_available_memory() / 1048576); + DDLogInfo(@"activity: %lu, memory used / available: %.3fMiB / %.3fMiB", counter, [self report_memory], (CGFloat)os_proc_available_memory() / 1048576); [NSThread sleepForTimeInterval:1]; } }); @@ -1405,26 +1405,42 @@ +(void) setFileLogger:(DDFileLogger*) fileLogger _fileLogger = fileLogger; } -+(NSData* _Nullable) convertLogmessageToJsonData:(DDLogMessage*) logMessage usingFormatter:(id _Nullable) formatter counter:(uint64_t*) counter andError:(NSError** _Nullable) error ++(NSData* _Nullable) convertLogmessageToJsonData:(DDLogMessage*) logMessage counter:(uint64_t*) counter andError:(NSError** _Nullable) error { - //format message using given formatter - NSString* logMsg = logMessage.message; - NSString* timestamp = [[NSISO8601DateFormatter new] stringFromDate:logMessage.timestamp]; - if(formatter) - { - logMsg = [NSString stringWithFormat:@"%@", [formatter formatLogMessage:logMessage]]; - timestamp = [(MLLogFormatter*)formatter stringFromDate:logMessage.timestamp]; - } + static NSDateFormatter* dateFormatter = nil; + static NSString* (^qos2name)(NSUInteger) = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + dateFormatter = [[NSDateFormatter alloc] init]; + [dateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4]; + [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss:SSS"]; + [dateFormatter setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"]]; + [dateFormatter setCalendar:[[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian]]; + + qos2name = ^(NSUInteger qos) { + switch ((qos_class_t) qos) { + case QOS_CLASS_USER_INTERACTIVE: return @"QOS_CLASS_USER_INTERACTIVE"; + case QOS_CLASS_USER_INITIATED: return @"QOS_CLASS_USER_INITIATED"; + case QOS_CLASS_DEFAULT: return @"QOS_CLASS_DEFAULT"; + case QOS_CLASS_UTILITY: return @"QOS_CLASS_UTILITY"; + case QOS_CLASS_BACKGROUND: return @"QOS_CLASS_BACKGROUND"; + default: return [NSString stringWithFormat:@"QOS_UNKNOWN(%lu)", (unsigned long)qos]; + } + }; + }); //construct json dictionary (*counter)++; NSDictionary* representedObject = @{ @"queueThreadLabel": [self getQueueThreadLabelFor:logMessage], @"processType": [self isAppExtension] ? @"appex" : @"mainapp", - @"representedObject": logMessage.representedObject ? logMessage.representedObject : [NSNull null] + @"processName": [[[NSBundle mainBundle] executablePath] lastPathComponent], + @"counter": [NSNumber numberWithUnsignedLongLong:*counter], + @"processID": _processID, + @"qosName": qos2name(logMessage.qos), + @"representedObject": logMessage.representedObject ? logMessage.representedObject : [NSNull null], }; NSDictionary* msgDict = @{ - @"formattedMessage": logMsg, @"messageFormat": logMessage.messageFormat, @"message": logMessage.message, @"level": [NSNumber numberWithInteger:logMessage.level], @@ -1436,13 +1452,11 @@ +(NSData* _Nullable) convertLogmessageToJsonData:(DDLogMessage*) logMessage usin @"line": [NSNumber numberWithInteger:logMessage.line], @"tag": representedObject, @"options": [NSNumber numberWithInteger:logMessage.options], - @"timestamp": timestamp, + @"timestamp": [dateFormatter stringFromDate:logMessage.timestamp], @"threadID": logMessage.threadID, @"threadName": logMessage.threadName, @"queueLabel": logMessage.queueLabel, @"qos": [NSNumber numberWithInteger:logMessage.qos], - @"_counter": [NSNumber numberWithUnsignedLongLong:*counter], - @"_processID": _processID, }; //encode json into NSData @@ -1467,22 +1481,16 @@ +(void) flushLogsWithTimeout:(double) timeout +(void) configureLogging { - //create log formatter - MLLogFormatter* formatter = [MLLogFormatter new]; - //don't log to the console (aka stderr) to not create loops with our redirected stderr // //start console logger first (this one will *not* log own additional (and duplicated) informations like DDOSLogger would) // #if TARGET_OS_SIMULATOR -// [[DDTTYLogger sharedInstance] setLogFormatter:formatter]; // [DDLog addLogger:[DDTTYLogger sharedInstance]]; // #else -// [[DDOSLogger sharedInstance] setLogFormatter:formatter]; // [DDLog addLogger:[DDOSLogger sharedInstance]]; // #endif //network logger (start as early as possible) MLUDPLogger* udpLogger = [MLUDPLogger new]; - [udpLogger setLogFormatter:formatter]; [DDLog addLogger:udpLogger]; //redirect stderr containing NSLog() messages @@ -1503,7 +1511,6 @@ +(void) configureLogging self.fileLogger.doNotReuseLogFiles = NO; self.fileLogger.rollingFrequency = 60 * 60 * 48; // 48 hour rolling self.fileLogger.maximumFileSize = 128 * 1024 * 1024; - self.fileLogger.logFormatter = formatter; self.fileLogger.archiveAllowed = YES; //everything is configured now, engage logfile archiving [DDLog addLogger:self.fileLogger]; @@ -1524,6 +1531,12 @@ +(void) configureLogging DDLogInfo(@"Starting: Version %@ (%@ %@ UTC, %@)", version, buildDate, buildTime, [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]); [DDLog flushLog]; + DDLogVerbose(@"QOS level: %@ = %d", @"QOS_CLASS_USER_INTERACTIVE", QOS_CLASS_USER_INTERACTIVE); + DDLogVerbose(@"QOS level: %@ = %d", @"QOS_CLASS_USER_INITIATED", QOS_CLASS_USER_INITIATED); + DDLogVerbose(@"QOS level: %@ = %d", @"QOS_CLASS_DEFAULT", QOS_CLASS_DEFAULT); + DDLogVerbose(@"QOS level: %@ = %d", @"QOS_CLASS_UTILITY", QOS_CLASS_UTILITY); + DDLogVerbose(@"QOS level: %@ = %d", @"QOS_CLASS_BACKGROUND", QOS_CLASS_BACKGROUND); + //remove old ascii based logfiles for(NSString* file in [[[NSFileManager defaultManager] contentsOfDirectoryAtPath:containerUrl error:nil] filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self LIKE %@", @"Monal *.log"]]) { @@ -1610,6 +1623,7 @@ +(void) installCrashHandler NSString* buildTime = [NSString stringWithUTF8String:__TIME__]; handler.userInfo = @{ @"isAppex": @([self isAppExtension]), + @"processName": [[[NSBundle mainBundle] executablePath] lastPathComponent], @"bundleName": nilWrapper([[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"]), @"appVersion": [NSString stringWithFormat:NSLocalizedString(@"Version %@ (%@ %@ UTC)", @""), version, buildDate, buildTime], }; diff --git a/Monal/Classes/MLConstants.h b/Monal/Classes/MLConstants.h index 8dc5851596..b7069b09dd 100644 --- a/Monal/Classes/MLConstants.h +++ b/Monal/Classes/MLConstants.h @@ -20,7 +20,6 @@ #define DDLogStdout(frmt, ...) LOG_MAYBE(NO, ddLogLevel, LOG_FLAG_STDOUT, 0, nil, __PRETTY_FUNCTION__, frmt, ##__VA_ARGS__) static const DDLogLevel ddLogLevel = LOG_LEVEL_STDOUT; #import "MLLogFileManager.h" -#import "MLLogFormatter.h" #import "MLFileLogger.h" diff --git a/Monal/Classes/MLFileLogger.m b/Monal/Classes/MLFileLogger.m index d881d9a577..f19613ccb8 100644 --- a/Monal/Classes/MLFileLogger.m +++ b/Monal/Classes/MLFileLogger.m @@ -115,7 +115,7 @@ -(NSData*) lt_dataForMessage:(DDLogMessage*) logMessage //encode log message NSError* error; - NSData* rawData = [HelperTools convertLogmessageToJsonData:logMessage usingFormatter:_logFormatter counter:&counter andError:&error]; + NSData* rawData = [HelperTools convertLogmessageToJsonData:logMessage counter:&counter andError:&error]; if(error != nil || rawData == nil) { NSLog(@"Error jsonifying log message: %@, logMessage: %@", error, logMessage); diff --git a/Monal/Classes/MLLogFormatter.h b/Monal/Classes/MLLogFormatter.h deleted file mode 100755 index 9964127109..0000000000 --- a/Monal/Classes/MLLogFormatter.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// MLLogFormatter.h -// monalxmpp -// -// Created by Thilo Molitor on 27.07.20. -// Copyright © 2020 Monal.im. All rights reserved. -// - -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface MLLogFormatter : DDDispatchQueueLogFormatter - --(NSString*) formatLogMessage:(DDLogMessage*) logMessage; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Monal/Classes/MLLogFormatter.m b/Monal/Classes/MLLogFormatter.m deleted file mode 100755 index 37e0ca7a5b..0000000000 --- a/Monal/Classes/MLLogFormatter.m +++ /dev/null @@ -1,70 +0,0 @@ -// -// MLLogFormatter.m -// monalxmpp -// -// Created by Thilo Molitor on 27.07.20. -// Copyright © 2020 Monal.im. All rights reserved. -// - -#import -#import -#import "MLConstants.h" -#import "MLLogFormatter.h" -#import "HelperTools.h" - -static DDQualityOfServiceName _qos_name(NSUInteger qos) { - switch ((qos_class_t) qos) { - case QOS_CLASS_USER_INTERACTIVE: return @"UI"; - case QOS_CLASS_USER_INITIATED: return @"IN"; - case QOS_CLASS_DEFAULT: return @"DF"; - case QOS_CLASS_UTILITY: return @"UT"; - case QOS_CLASS_BACKGROUND: return @"BG"; - default: return @"UN"; - } -} - -static inline NSString* _loglevel_name(NSUInteger flag) { - if(flag & DDLogLevelOff) - return @" OFF"; - else if(flag & DDLogLevelError) - return @" ERROR"; - else if(flag & DDLogLevelWarning) - return @" WARN"; - else if(flag & DDLogLevelInfo) - return @" INFO"; - else if(flag & DDLogLevelDebug) - return @" DEBUG"; - else if(flag & DDLogLevelVerbose) - return @" VERB"; - else if(flag & LOG_LEVEL_STDERR) - return @"STDERR"; - else if(flag & LOG_LEVEL_STDOUT) - return @"STDOUT"; - else if(flag & DDLogLevelAll) - return @" ALL"; - return @" UNKN"; -} - -@implementation MLLogFormatter - --(NSString*) formatLogMessage:(DDLogMessage*) logMessage -{ - NSArray* filePathComponents = [logMessage.file pathComponents]; - NSString* file = logMessage.file; - if([filePathComponents count]>1) - file = [NSString stringWithFormat:@"%@/%@", filePathComponents[[filePathComponents count]-2], filePathComponents[[filePathComponents count]-1]]; - NSString* timestamp = [self stringFromDate:logMessage.timestamp]; - NSString* queueThreadLabel = [HelperTools getQueueThreadLabelFor:logMessage]; - - //append the mach thread id if not already present - if(![queueThreadLabel isEqualToString:logMessage.threadID]) - queueThreadLabel = [NSString stringWithFormat:@"%@:%@", logMessage.threadID, queueThreadLabel]; - - //don't format stdout and stderr logmessages, e.g. don't add metadata to logline (only to json) - if(logMessage.flag & LOG_FLAG_STDOUT || logMessage.flag & LOG_FLAG_STDERR) - return logMessage.message; - - return [NSString stringWithFormat:@"%@ [%@] %@ [%@ (QOS:%@)] %@ at %@:%lu: %@", timestamp, _loglevel_name(logMessage.flag), [HelperTools isAppExtension] ? @"*appex*" : @"mainapp", queueThreadLabel, _qos_name(logMessage.qos), logMessage.function, file, (unsigned long)logMessage.line, logMessage.message]; -} - -@end diff --git a/Monal/Classes/MLUDPLogger.m b/Monal/Classes/MLUDPLogger.m index 3cc0c799ce..81d19776ab 100644 --- a/Monal/Classes/MLUDPLogger.m +++ b/Monal/Classes/MLUDPLogger.m @@ -233,16 +233,13 @@ -(void) logMessage:(DDLogMessage*) logMessage return; NSError* error = nil; - NSData* rawData = [HelperTools convertLogmessageToJsonData:logMessage usingFormatter:self->_logFormatter counter:&counter andError:&error]; + NSData* rawData = [HelperTools convertLogmessageToJsonData:logMessage counter:&counter andError:&error]; if(error != nil || rawData == nil) { [[self class] logError:@"json encode error: %@", error]; return; } - //you have to uncomment the following line to send only the formatted logline - //rawData = [logMsg dataUsingEncoding:NSUTF8StringEncoding]; - //compress data to account for udp size limits rawData = [self gzipDeflate:rawData]; diff --git a/Monal/Monal.xcodeproj/project.pbxproj b/Monal/Monal.xcodeproj/project.pbxproj index 8be78ec498..d1e21cb932 100644 --- a/Monal/Monal.xcodeproj/project.pbxproj +++ b/Monal/Monal.xcodeproj/project.pbxproj @@ -100,8 +100,6 @@ 540E13A024CDCDB30038FDA0 /* MLProcessLock.m in Sources */ = {isa = PBXBuildFile; fileRef = 540E139F24CDCDB30038FDA0 /* MLProcessLock.m */; }; 540E13A224CDCE3B0038FDA0 /* MLProcessLock.h in Headers */ = {isa = PBXBuildFile; fileRef = 540E13A124CDCE3B0038FDA0 /* MLProcessLock.h */; }; 540E13A524CF6A8C0038FDA0 /* MLNotificationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 26EE8B1E179B67FA006781F3 /* MLNotificationManager.m */; }; - 540E13A724CF78900038FDA0 /* MLLogFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 540E13A624CF78900038FDA0 /* MLLogFormatter.m */; }; - 540E13A924CF78D00038FDA0 /* MLLogFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = 540E13A824CF78D00038FDA0 /* MLLogFormatter.h */; }; 540F625F24BA951E0008A6D8 /* HelperTools.m in Sources */ = {isa = PBXBuildFile; fileRef = C1AAC3E324B5EF4100BB15D6 /* HelperTools.m */; }; 54179CC0251CBAFA008F398E /* XMPPStanza.m in Sources */ = {isa = PBXBuildFile; fileRef = 54179CBF251CBAF9008F398E /* XMPPStanza.m */; }; 54179CC3251CBB2B008F398E /* XMPPStanza.h in Headers */ = {isa = PBXBuildFile; fileRef = 54179CC2251CBB2B008F398E /* XMPPStanza.h */; }; @@ -515,8 +513,6 @@ 540BD0D324D8D1FF0087A743 /* IPC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IPC.m; sourceTree = ""; }; 540E139F24CDCDB30038FDA0 /* MLProcessLock.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MLProcessLock.m; sourceTree = ""; }; 540E13A124CDCE3B0038FDA0 /* MLProcessLock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MLProcessLock.h; sourceTree = ""; }; - 540E13A624CF78900038FDA0 /* MLLogFormatter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MLLogFormatter.m; sourceTree = ""; }; - 540E13A824CF78D00038FDA0 /* MLLogFormatter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MLLogFormatter.h; sourceTree = ""; }; 54179CBF251CBAF9008F398E /* XMPPStanza.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XMPPStanza.m; sourceTree = ""; }; 54179CC2251CBB2B008F398E /* XMPPStanza.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XMPPStanza.h; sourceTree = ""; }; 541B6AB2262BC9040038B936 /* MLStream.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MLStream.m; sourceTree = ""; }; @@ -1227,8 +1223,6 @@ C1AAC3E324B5EF4100BB15D6 /* HelperTools.m */, 540E139F24CDCDB30038FDA0 /* MLProcessLock.m */, 540E13A124CDCE3B0038FDA0 /* MLProcessLock.h */, - 540E13A624CF78900038FDA0 /* MLLogFormatter.m */, - 540E13A824CF78D00038FDA0 /* MLLogFormatter.h */, 541E4CBD254AA0B600FD7B28 /* MLHandler.h */, 541E4CBF254AA0E700FD7B28 /* MLHandler.m */, C10490482612ED2F0054AC9E /* MLEmoji.swift */, @@ -1457,7 +1451,6 @@ 542CF4002763314F002C3710 /* hsluv.h in Headers */, 54E594BD2523C34B00E4172B /* MLPubSub.h in Headers */, 540BD0D224D8D1F40087A743 /* IPC.h in Headers */, - 540E13A924CF78D00038FDA0 /* MLLogFormatter.h in Headers */, C1C839DD24F15DF800BBCF17 /* MLOMEMO.h in Headers */, 841EE42B2A3F471100D3AF14 /* MLFileLogger.h in Headers */, 26D4389123A5EB6C00242AAA /* MLConstants.h in Headers */, @@ -2128,7 +2121,6 @@ 26CC57A223A086AA00ABB92A /* xmpp.m in Sources */, 26CC57B423A086CC00ABB92A /* XMPPPresence.m in Sources */, 541E4CC0254AA0E700FD7B28 /* MLHandler.m in Sources */, - 540E13A724CF78900038FDA0 /* MLLogFormatter.m in Sources */, 841EE4292A3F46F700D3AF14 /* MLFileLogger.m in Sources */, C158D41425A0AC630005AA40 /* MLMucProcessor.m in Sources */, C16D18362792A4AF00F869A0 /* DataLayerMigrations.m in Sources */, diff --git a/UDPLogServer/server.py b/UDPLogServer/server.py index 39d5dd292d..e7a963cc0f 100755 --- a/UDPLogServer/server.py +++ b/UDPLogServer/server.py @@ -7,6 +7,7 @@ import zlib import hashlib import struct +import pathlib def eprint(*args, **kwargs): print(*args, file=sys.stderr, **kwargs) @@ -65,6 +66,30 @@ def decrypt(ciphertext, key): raise Exception("Cipher text is damaged: {}".format(e)) return plaintext +def formatLogline(entry): + LOGLEVELS = {v: k for k, v in { + "ERROR": 1, + "WARNING": 2, + "INFO": 4, + "DEBUG": 8, + "VERBOSE": 16, + "STDERR": 32, + "STDOUT": 64, + "STATUS": 256, + }.items()} + file = pathlib.PurePath(entry["file"]) + return "%s [%s] %s [%s (QOS:%s)] %s at %s:%lu: %s" % ( + entry["timestamp"], + LOGLEVELS[entry["flag"]].rjust(6), + entry["tag"]["processName"], + "%s:%s" % (entry["threadID"], entry["tag"]["queueThreadLabel"]) if entry["threadID"] != entry["tag"]["queueThreadLabel"] else entry["threadID"], + entry["tag"]["qosName"], + entry["function"], + "%s/%s" % (file.parent.name, file.name), + entry["line"], + entry["message"], + ) + # parse commandline parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, description="Monal UDP-Logserver.", epilog="WARNING: WE DO NOT ENHANCE ENTROPY!! PLEASE MAKE SURE TO USE A ENCRYPTION KEY WITH PROPER ENTROPY!!") parser.add_argument("-k", "--key", type=str, required=True, metavar='KEY', help="AES-Key to use for decription of incoming data") @@ -119,14 +144,14 @@ def decrypt(ciphertext, key): receiveCounter += 1 decoded["_receiveCounter"] = receiveCounter - # check if _counter jumped over some lines + # check if counter jumped over some lines logline = "" - if "_processID" in decoded and last_processID != None and decoded["_processID"] != last_processID: - logline += "PROCESS SWITCH FROM %s TO %s" % (last_processID, decoded["_processID"]) - if "_counter" in decoded and last_counter != None and decoded["_counter"] != last_counter + 1: + if last_processID != None and decoded["tag"]["processID"] != last_processID: + logline += "PROCESS SWITCH FROM %s TO %s" % (last_processID, decoded["tag"]["processID"]) + if last_counter != None and decoded["tag"]["counter"] != last_counter + 1: if len(logline) != 0: logline += ": " - logline += "counter jumped from %d to %d leaving out %d lines" % (last_counter, decoded["_counter"], decoded["_counter"] - last_counter - 1) + logline += "counter jumped from %d to %d leaving out %d lines" % (last_counter, decoded["tag"]["counter"], decoded["tag"]["counter"] - last_counter - 1) if len(logline) != 0: if logfd: print(logline, file=logfd) @@ -136,13 +161,11 @@ def decrypt(ciphertext, key): kwargs = flag_to_kwargs(decoded["flag"] if "flag" in decoded else None) # print original formatted log message - logline = ("%d: %s" % (decoded["_counter"], str(decoded["formattedMessage"]).rstrip())) + logline = ("%d: %s" % (decoded["tag"]["counter"], formatLogline(decoded))) if logfd: print(logline, file=logfd) print(colorize(logline, **kwargs), flush=True) # update state - if "_processID" in decoded: - last_processID = decoded["_processID"] - if "_counter" in decoded: - last_counter = decoded["_counter"] + last_processID = decoded["tag"]["processID"] + last_counter = decoded["tag"]["counter"]