Important notice - 06 April 2013

All eosgarden activities have been closed forever, in order to focus on new projects.
The content of this website will stay as is, for archive purpose, but won't be updated anymore.
eosgarden software are still available for download, but are no longer maintained. Support is no longer available.


All our OpenSource projects have been migrated to GitHub.
Feel free to fork!


Obj-C Extended Log is a replacement library for the for the built-in NSLog() function, from the Apple Core Foundation framework.
It provides better logging informations, as well as fome usefull macros to help various data-structures of the Core Foundation Framework.
Obj-C Extended Log is release under the Boost License. It means you can use it freely with your projects, without giving credits, as long as you only release object code.

Table of contents

  1. Features
  2. Usage
  3. Macros


The NSLog() function is often used while developping Objective-C applications to output debug informations on the console.
Unfortunately, its output is pretty basic.
For instance, the following code:
NSArray * arr = [ NSArray arrayWithObjects: @"hello", @"world", nil ];
NSLog( @"This is an array: %@", arr );
The following will be outputted on the console:
2010-08-05 19:20:00.901 test[39730:903] This is an array: (
With the Obj-C Extended Log library, the very same code will produce the following output:
Log informations:

- File: ./file.m
- Line: 42
- PID: 170582
- Thread: 1 - <Main>
- Time: 2010-08-05 19:42:24.000


This is an array: (
As you can see, it provides additionnal informations that can be useful for debug prupose, like the file name and line number in which the log was made, the process and thread number, etc.
The library also includes usefull macros, to help with the Core Foundation structures.
For instance:
NSRect rect = NSMakeRect( 0, 0, 100, 200 );
The NSRect C structure represents a rectangle. It contains two members:
  • position
    A NSPoint structure, containing two float members: x & y
  • size
    A NSSize structure, containing two float members: width & height
You can't passed such a structure directly to the built-in NSLog function.
But with the Obj-C Extended Log library, you can use the 'LogRect' macro to automatically log each member of the structure:
LogRect( rect );
Which will display:
Log informations:

- File: ./file.m
- Line: 42
- PID: 170582
- Thread: 1 - <Main>
- Time: 2010-08-05 19:42:24.000


X: 0
Y: 0
Width: 100
Height: 200


The library consist of a header file (.h), and a source file (.m).
You can either include it directly into your project, or compile it separately as a static library, linked with your binary.
To enable the extended log, you simply need to include the header file.
You don't need to change your code, as it will replace the built-in NSLog() function.
For instance, a Objective-C main routine:
#import <Foundation/Foundation.h>
#import "libobj_log.h"

int main( void )
NSAutoreleasePool * ap;

ap = [ NSAutoreleasePool new ];

NSLog( @"hello, %@", @"world" );

[ ap drain ];

The extended log will be automatically enabled when including the header file.
Log informations will be displayed on 'stderr', as well as on the Apple console (, using the Apple System Logger API (ASL).
You can control what's logged on the Apple Console by defining two constants.
These constants must be defined before including the header file:
#import "libobj_log.h"
If this is defined, the extended log informations will be displayed on stderr, but a standard log will be displayed on the Apple console (exactly like the built-in NSLog() function).
#import "libobj_log.h"
If this is defined, the extended log informations will be displayed on stderr, but not on the Apple console.


NSLog( NSString * fmt, ... )
The replacement for the built-in NSLog() function.
Takes a NSString * for the format, and optional arguments, depending on the format.
LogPoint( NSPoint p )
LogPoint( CGPoint p )
Logs a NSPoint/CGPoint structure. Members are x, y.
LogSize( NSSize s )
LogSize( CGSize s )
Logs a NSSize/CGSize structure. Members are width, height.
LogRect( NSRect r )
LogRect( CGRect r )
Logs a NSRect/CGRect structure. Members are x, y, width, height.
LogRange( NSRange r )
Logs a NSRange structure. Members are location, length.
LogEdgeInsets( UIEdgeInsets e )
Only available for iPhone OS
Logs a UIEdgeInsets structure. Members are top, left, bottom, right.