Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoRotatingFileDestination Crash some times #278

Open
Zeropointer11 opened this issue Feb 19, 2019 · 2 comments
Open

AutoRotatingFileDestination Crash some times #278

Zeropointer11 opened this issue Feb 19, 2019 · 2 comments

Comments

@Zeropointer11
Copy link

Zeropointer11 commented Feb 19, 2019

Hi i use the XCGLogger Version 6.1.0 github "DaveWoodCom/XCGLogger" "6.1.0" and get sometimes the File Rotataion Crash at syncronizeFile()
may be you will add a Lock on the File Handler to fix it?

private func closeFile() { logFileHandle?.synchronizeFile() logFileHandle?.closeFile() logFileHandle = nil }

Here is the Crash Report

`
Application Specific Information:
*** Terminating app due to uncaught exception 'NSFileHandleOperationException', reason: '*** -[NSConcreteFileHandle synchronizeFile]: No such file or directory'

Last Exception Backtrace:
0 CoreFoundation 0x00000001948c4ec4 __exceptionPreprocess + 228
1 libobjc.A.dylib 0x0000000193a95a40 objc_exception_throw + 52
2 CoreFoundation 0x00000001947cb594 +[NSException raise:format:] + 112
3 Foundation 0x0000000195318610 NSFileHandleRaiseOperationException + 156 4 XCGLogger 0x000000010d25a38c XCGLogger.FileDestination.rotateFile(to: Any, closure: (Swift.Bool) -> ()?) -> Swift.Bool (FileDestination.swift:137) 5 XCGLogger 0x000000010d249478 XCGLogger.AutoRotatingFileDestination.rotateFile() -> () (AutoRotatingFileDestination.swift:237) 6 XCGLogger 0x000000010d249768 XCGLogger.AutoRotatingFileDestination.write(message: Swift.String) -> () (AutoRotatingFileDestination.swift:283) 7 XCGLogger 0x000000010d23902c closure #1 () -> () in XCGLogger.BaseQueuedDestination.output(logDetails: XCGLogger.LogDetails, message: Swift.String) -> () (BaseQueuedDestination.swift:41) 8 XCGLogger 0x000000010d238bcc XCGLogger.BaseQueuedDestination.output(logDetails: XCGLogger.LogDetails, message: Swift.String) -> () (BaseQueuedDestination.swift:48) 9 XCGLogger 0x000000010d23ea8c XCGLogger.BaseDestination.process(logDetails: XCGLogger.LogDetails) -> () (BaseDestination.swift:124) 10 XCGLogger 0x000000010d2400c4 protocol witness for XCGLogger.DestinationProtocol.process(logDetails: XCGLogger.LogDetails) -> () in conformance XCGLogger.BaseDestination : XCGLogger.DestinationProtocol in XCGLogger (:0) 11 XCGLogger 0x000000010d25dff8 XCGLogger.XCGLogger.logln(: XCGLogger.XCGLogger.Level, functionName: Swift.String, fileName: Swift.String, lineNumber: Swift.Int, userInfo: [Swift.String : Any], closure: () -> Any?) -> () (XCGLogger.swift:335)
12 XCGLogger 0x000000010d25dc7c XCGLogger.XCGLogger.logln(: XCGLogger.XCGLogger.Level, functionName: Swift.StaticString, fileName: Swift.StaticString, lineNumber: Swift.Int, userInfo: [Swift.String : Any], closure: () -> Any?) -> () (XCGLogger.swift:313) 13 XCGLogger 0x000000010d25f9d0 merged XCGLogger.XCGLogger.verbose(: @autoclosure () -> Any?, functionName: Swift.StaticString, fileName: Swift.StaticString, lineNumber: Swift.Int, userInfo: [Swift.String : Any]) -> () + 144
14 XCGLogger 0x000000010d25f2ac XCGLogger.XCGLogger.warning(: @autoclosure () -> Any?, functionName: Swift.StaticString, fileName: Swift.StaticString, lineNumber: Swift.Int, userInfo: [Swift.String : Any]) -> () + 28 15 Ticketing-Offline 0x00000001031135b4 generic specialization <Ticketing_Offline.TSDataImageDownloadResponse> of closure #3 (Alamofire.DefaultDownloadResponse) -> () in closure #1 (RxSwift.AnyObserver) -> RxSwift.Disposable in Ticketing_Offline.TSAPIService.download(: Swift.String, destinationPath: Swift.String, method: Alamofire.HTTPMethod, parameters: [Swift.String : Any]?, headers: [Swift.String : Swift.String]?) -> RxSwift.Observable (TSAPIService.swift:390)
`

@ehmjaysee
Copy link

Hi, are you configuring your log to use background processing? i.e.
fileDestination.logQueue = XCGLogger.logQueue

If yes then you may be hitting the same issue I reported here: #260

When you enable background processing a crash can occur if there are any messages waiting in the log message queue when the rotation happens. The rotation code will close the old file and open a new file. Later on the background thread runs and tries to write log messages to the old file which was just closed by the rotation logic. Writing to a stale file ID causes the crash.

@Zeropointer11
Copy link
Author

Hi, ehmjaysee yes i am using the logQueue for processing it in Background. But i have add it to fix the AutoRotate crashes. For a smal amount of time it looks like the crash was fixed but it was not. When i did not set the logQueue it Crashs on every file Rotation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants