Skip to content
forked from ca-archived/NBULog

Log framework based on CocoaLumberjack. Adds dynamic log levels, modules' support and eases usage.

License

Notifications You must be signed in to change notification settings

PTEz/iOS-NBULog

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NBULog

Platform: iOS Version: 1.0.0 Build Status

Log framework based on CocoaLumberjack. Adds dynamic log levels, modules' support and eases usage.

Was part of NBUCore 1.9.x.

Installation

Add pod 'NBULog' to your CocoaPods' Podfile:

platform :ios, '5.0'

pod 'NBULog'

# Optional on-device console
pod 'LumberjackConsole'

Features

Dynamic Log Levels

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

Modules

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

XcodeColors

XcodeColors

When installed, XcodeColors are automatically enabled for the Xcode console.

On-Device Log Console and GUI to Ajust Levels

LumberjackConsole 1 LumberjackConsole 2

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

Documentation

http://cocoadocs.org/docsets/NBULog/

License

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.

About

Log framework based on CocoaLumberjack. Adds dynamic log levels, modules' support and eases usage.

Resources

License

Stars

Watchers

Forks

Packages

No packages published