Log framework based on CocoaLumberjack. Adds dynamic log levels, modules' support and eases usage.
Was part of NBUCore 1.9.x.
Add pod 'NBULog'
to your CocoaPods' Podfile:
platform :ios, '5.0'
pod 'NBULog'
# Optional on-device console
pod 'LumberjackConsole'
Instead of handling a ddLogLevel
variable set you app log level dynamically. Also works with third party libraries that support NBULog.
[NBULog setAppLogLevel:LOG_LEVEL_INFO];
[NBULog setKitLogLevel:LOG_LEVEL_WARN]; // When using NBUKit
By default all your sources to APP_MODULE_DEFAULT
but you can define your own modules in your prefix.pch
file.
// Custom log modules
#define APP_MODULE_NETWORK 1 // APP_MODULE_DEFAULT = 0
#define APP_MODULE_OTHER 2
Then just redefine APP_MODULE
for the files that belong to one of your custom modules.
#import "MockNetworkModule.h"
// Define log module for this file
#undef APP_MODULE
#define APP_MODULE APP_MODULE_NETWORK
Also you log a message for a different module than the one your file belongs to:
// Send an extra message for another module
NBULogInfoWithModule(APP_MODULE_OTHER, @"Log message from a APP_MODULE_OTHER");
Finally, you can also modify the log levels of individual modules.
// Only log messages from the custom APP_MODULE_NETWORK
[NBULog setAppLogLevel:LOG_LEVEL_OFF];
[NBULog setAppLogLevel:LOG_LEVEL_INFO
forModule:APP_MODULE_NETWORK];
[NBULog setKitLogLevel:LOG_LEVEL_WARN
forModule:NBUKIT_MODULE_ADDITIONS]; // When using NBUKit
When installed, XcodeColors are automatically enabled for the Xcode console.
When LumberjackConsole is present you can add am on-device dashboard logger and adjust log levels from the UI.
#ifndef MY_PRODUCTION_MACRO
// Register custom modules before adding the dashboard
[NBULog registerAppContextWithModulesAndNames:@{@(APP_MODULE_NETWORK) : @"Network",
@(APP_MODULE_OTHER) : @"Other"}];
// Add dashboard only for testing builds
[NBULog addDashboardLogger];
#endif
http://cocoadocs.org/docsets/NBULog/
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.