Is XCGLogger thread safe?

I'm considering using XCGLogger

CocoaLumberjack as a replacement and would like to know if it is allowed to log the following from any thread using the global log created and configured on the main thread as per the README?

log.info("This is not a valid format: \(inputStr)")

      

+3


source to share


1 answer


TL; DR: Yes, it XCGLogger

is thread safe, but it uses println()

which itself is truly safe, so other callers println()

can make it look as if it XCGLogger

was not itself.

XCGLogger

uses a queue to ensure that all calls are println()

called and executed by a safe thread.



Please note that if you call println()

directly from somewhere else in your application or to another library, these calls are not thread safe and may interfere with calls from XCGLogger

.

The project has a unit test ( testMultiThreaded

) that shows multiple calls XCGLogger

through a parallel queue and they all write safely. But you can see that Xcode itself is outputting information about tests as they run and that the output can get confused with the log output.

+7


source







All Articles