Home

Awesome

Macro-Logger

A simplified logging system using macros for C/C++ and Objective-C.

Notes

Levels

There are three different logging levels. It's possible also disable all logs.

The log level can be specified on compilation time using the macro

LOG_LEVEL=level_number

If not specified is used the debug level.

Technical aspects

Basic usage

The only file needed to use the macrologger is the header file, macrologger.h.


// C/C++
#include "macrologger.h"

// Objective-C
#import "macrologger.h"

Available functions



LOG_DEBUG(message, arguments);

LOG_INFO(message, arguments);

LOG_ERROR(message, arguments);

LOG_IF_ERROR(condition, message, arguments);

Examples



// C/C++ strings
LOG_DEBUG("Maybe i can touch this button...");
    
// Objective-C strings
LOG_INFO("@Pressure is dropping...");

// printing Objective-C objects    
NSString *baseStation = @"Houston";
LOG_ERROR(@"%@ we have a problem!", baseStation);

int going_down = 1;
LOG_IF_ERROR(going_down, "i'm going down... if only i had used macro-logger...");

Sample output

2012-09-04 01:05:16 | DEBUG   | sample.m        | main:29 | Maybe i can touch this button...
2012-09-04 01:05:16 | INFO    | sample.m        | main:31 | Pressure is dropping...
2012-09-04 01:05:16 | ERROR   | sample.m        | main:34 | Houston we have a problem!
2012-09-04 01:05:16 | ERROR   | sample.m        | main:37 | i'm going down... if only i had used macro-logger...