mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 22:23:31 +00:00
added ability to tag logs for easier filtering
This commit is contained in:
@@ -24,5 +24,6 @@ typedef enum {
|
|||||||
#define PRFX_ERROR @"<ERROR>"
|
#define PRFX_ERROR @"<ERROR>"
|
||||||
|
|
||||||
void Log(LogLevel level, NSString* fmt, ...);
|
void Log(LogLevel level, NSString* fmt, ...);
|
||||||
|
void LogTag(LogLevel level, NSString* tag, NSString* fmt, ...);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,7 +8,23 @@
|
|||||||
|
|
||||||
#import "Logger.h"
|
#import "Logger.h"
|
||||||
|
|
||||||
|
void LogTagv(LogLevel level, NSString* tag, NSString* fmt, va_list args);
|
||||||
|
|
||||||
void Log(LogLevel level, NSString* fmt, ...) {
|
void Log(LogLevel level, NSString* fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
LogTagv(level, NULL, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogTag(LogLevel level, NSString* tag, NSString* fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
LogTagv(level, tag, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogTagv(LogLevel level, NSString* tag, NSString* fmt, va_list args) {
|
||||||
NSString* levelPrefix = @"";
|
NSString* levelPrefix = @"";
|
||||||
|
|
||||||
switch(level) {
|
switch(level) {
|
||||||
@@ -27,9 +43,11 @@ void Log(LogLevel level, NSString* fmt, ...) {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
NSString* prefixedString = [NSString stringWithFormat:@"%@ %@", levelPrefix, fmt];
|
NSString* prefixedString;
|
||||||
va_list args;
|
if (tag) {
|
||||||
va_start(args, fmt);
|
prefixedString = [NSString stringWithFormat:@"%@ (%@) %@", levelPrefix, tag, fmt];
|
||||||
|
} else {
|
||||||
|
prefixedString = [NSString stringWithFormat:@"%@ %@", levelPrefix, fmt];
|
||||||
|
}
|
||||||
NSLogv(prefixedString, args);
|
NSLogv(prefixedString, args);
|
||||||
va_end(args);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user