CocoaLumberjack for logging in one of the projects. Now the client wants the ability to change the log level at runtime in Settings. The official article (https://github.com/robbiehanson/CocoaLumberjack/wiki/DynamicLogLevels) suggests a simple solution: remove the
const modifier from the definition of
ddLogLevel, so you change it in runtime. However, if this var is defined in the shared precompiled header (
project.pch file), every source code file gets its own copy.
To make it global, here’s my workaround: create a pair of files:
AppLogging.m. Instead of declaring the
ddLogLevel variable in the
AppLogging.h file, where you move it to:
Now, the whole program has access to this variable, being able to change the log level globally.