DaveWoodCom / XCGLogger

A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

File append marker written twice

kchlebus opened this issue · comments

Hi,
when I'm using shouldAppend: true option for FileDestination, after each restart file contains two append markers. That should be one append marker for one app restart. I've tried configuring XCGLogger in different ways and places, and always got the same results. The simplest configuration that causes that issue (in AppDelegate file):

let log: XCGLogger = {
    let log = XCGLogger(identifier: "advancedLogger", includeDefaultDestinations: false)
    let logPath: URL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first!.appendingPathComponent("XCGLogger_Log.txt")
    let fileDestination = AutoRotatingFileDestination(owner: log, writeToFile: logPath, identifier: "advancedLogger.fileDestination", shouldAppend: true, appendMarker: "-- Relauched App --")
    fileDestination.outputLevel = .debug
    log.add(destination: fileDestination)
    return log
}()

Marker -- Relauched App -- is written always two times for each app restart.

Example file content after one app restart:

2018-11-07 11:36:04.559 [Info] > MyApp Version: 5.0.0 Build: 71 PID: 21908
2018-11-07 11:36:04.559 [Info] > XCGLogger Version: 6.1.0 - Level: Debug
2018-11-07 11:36:04.561 [Info] > XCGLogger writing log to: file:///Users/kchlebus/Library/Developer/CoreSimulator/Devices/6E1A0127-2499-404A-847F-153ADC2901F5/data/Containers/Data/Application/586907DA-4088-4F8B-B636-341270110AE5/Library/Caches/XCGLogger_Log.txt
-- Relauched App --
2018-11-07 11:36:04.563 [Info] > XCGLogger appending log to: file:///Users/kchlebus/Library/Developer/CoreSimulator/Devices/6E1A0127-2499-404A-847F-153ADC2901F5/data/Containers/Data/Application/586907DA-4088-4F8B-B636-341270110AE5/Library/Caches/XCGLogger_Log.txt
2018-11-07 11:36:04.563 [Debug] [LoginViewController.swift:25] viewDidLoad() > Some test debug LOG message
-- Relauched App --
2018-11-07 11:36:43.352 [Info] > MyApp Version: 5.0.0 Build: 71 PID: 22185
2018-11-07 11:36:43.352 [Info] > XCGLogger Version: 6.1.0 - Level: Debug
2018-11-07 11:36:43.354 [Info] > XCGLogger appending log to: file:///Users/kchlebus/Library/Developer/CoreSimulator/Devices/6E1A0127-2499-404A-847F-153ADC2901F5/data/Containers/Data/Application/F01DE0B8-A203-4FD5-B9CA-07C96F655E3F/Library/Caches/XCGLogger_Log.txt
-- Relauched App --
2018-11-07 11:36:43.355 [Info] > XCGLogger appending log to: file:///Users/kchlebus/Library/Developer/CoreSimulator/Devices/6E1A0127-2499-404A-847F-153ADC2901F5/data/Containers/Data/Application/F01DE0B8-A203-4FD5-B9CA-07C96F655E3F/Library/Caches/XCGLogger_Log.txt
2018-11-07 11:36:43.355 [Debug] [LoginViewController.swift:25] viewDidLoad() > Some test debug LOG message

Xcode 10.1
iOS 12.1
XCGLogger 6.1.0 installed via CocoaPods 1.5.3

Any solution?

I would be glad if any file was written on my device..l.