Logging: Tag the entries in the merged log

So we know which entry is from the app and which is from the network
extension.

Signed-off-by: Roopesh Chander <roop@roopc.net>
This commit is contained in:
Roopesh Chander
2018-12-13 18:00:32 +05:30
parent ba1d0c05be
commit e199ed0d6c
4 changed files with 14 additions and 7 deletions
+7 -3
View File
@@ -14,14 +14,18 @@ class Logger {
return (logPtr != nil)
}
static func writeLog(mergedWith otherLogFile: String, to targetFile: String) -> Bool {
static func writeLog(mergedWith otherLogFile: String, tag: String, otherTag: String, to targetFile: String) -> Bool {
let otherlogPtr = otherLogFile.withCString { otherLogFileCStr -> UnsafeMutablePointer<log>? in
return open_log(otherLogFileCStr)
}
if let thisLogPtr = Logger.logPtr, let otherlogPtr = otherlogPtr {
return targetFile.withCString { targetFileCStr -> Bool in
let returnValue = write_logs_to_file(targetFileCStr, thisLogPtr, otherlogPtr)
return (returnValue == 0)
return tag.withCString { tagCStr -> Bool in
return otherTag.withCString { otherTagCStr -> Bool in
let returnValue = write_logs_to_file(targetFileCStr, tagCStr, thisLogPtr, otherTagCStr, otherlogPtr)
return (returnValue == 0)
}
}
}
}
return false