NXVLogFormatter 0.0.2

NXVLogFormatter 0.0.2

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Dec 2014

Maintained by Unclaimed.




Build Status

Simple custom log formatter for the awesome CocoaLumberjack.

It logs output with following pattern:

(Date, Time) -[FileName MethodName](line number): "LogMessage"

Why?

Because traditional NSLog() is not debug-friendly et al

How

Just add couple lines and you are up and running

// first, you need to import CocoaLumberjack files
#import "DDLog.h"
#import "DDTTYLogger.h"
#import "DDASLLogger.h"

// then, you could also add NXVLogFormatter whenever you need it 
#import "NXVLogFormatter.h"

// setup logger
- (void)initializeLogger
{
  // required, setup DDLog
  [DDLog addLogger:[DDASLLogger sharedInstance]];
  [DDLog addLogger:[DDTTYLogger sharedInstance]];

  // use NXVLogFormatter as custom log formmater
  [[DDTTYLogger sharedInstance] setLogFormatter:[NXVLogFormatter new]];

  // optional, enable colors
  [[DDTTYLogger sharedInstance] setColorsEnabled:YES];
}


// then in application:didFinishLaunchingWithOptions:, just bind 
// that log method to it
- (BOOL)              application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

  // initialize it
  [self initializeLogger];

  // ...

  return YES;
}

Screenshot

Here is what it looks like with CocoaLumberjack's built-in color mode in Xcode Console. screenshot

Installation

Automatic

If you use Cocoapods, you can add pod 'NXVLogFormatter' to your Podfile. Then run pod install to integrate NXVLogFormatter to your project, like so:

# somewhere in your Podfile
pod 'NXVLogFormatter'

then just install and open your project's workspace:

pod install --verbose && YourProject.xcworkspace

Manually

Just drag both NXVLogFormatter.{h,m} files to your project and start using it like this.

License

See LICENSE.

Contact

I'm @vinhnx on almost anywhere.

Bitdeli Badge