I found the answer in the DDLog.h
file. Lumberjack has the concept of asynchronous and synchronous logging. At initial read, it didn't hit me as to what this was for.
Basically, if you want the log statement to be output in sequence, one needs to make it synchronized (though, as Mike mentioned, this will slow down performance). So, this should only be done in a debugging situation. Ideally, I'll put another header together and/or some other pre-processor macro to ensure I don't leave the switch flipped on as synchronous.
Here's what you do:
- Open up
DDLog.h
- Go to the line with
#define LOG_ASYNC_ENABLED YES
. You can change this to NO
in one spot for synchronous logging across the board, or you can change individual levels, in the lines that follow.
Note that the header discourages changing the DDLog.h file itself. So, following the instructions on the Lumberjack wiki page link, they explain how to use a different header file to articulate these override customizations.
Using that, here's what I've successfully written and tested, as "MyAppLumberjack.h" header file that I import in my app's precompiled header:
#import "DDLog.h"
#import "DDASLLogger.h"
#import "DDTTYLogger.h"
// ========================= Overrides ========================================
// --> per https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomLogLevels
// ----------------------------------------------------------------------------
// Are we in an optimized (i.e. Release) build?
#ifdef __OPTIMIZE__
// YES: Nothing to do from the default. (You could simplify this by using #ifndef above instead)
#else
// NO: We're in a Debug build. As such, let's configure logging to flush right away.
// Undefine the asynchronous defaults:
#undef LOG_ASYNC_VERBOSE
#undef LOG_ASYNC_INFO
#undef LOG_ASYNC_WARN
// Define the logs levels to be synchronous:
#define LOG_ASYNC_VERBOSE (NO && LOG_ASYNC_ENABLED) // Debug logging will be synchronous
#define LOG_ASYNC_INFO (NO && LOG_ASYNC_ENABLED) // Info logging will be synchronous
#define LOG_ASYNC_WARN (NO && LOG_ASYNC_ENABLED) // Warn logging will be synchronous
#endif