Is XCGLogger thread safe?
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.
source to share