Logahawk Logo
Logahawk
Logging should be easy - Easy to code and easy to read
ArgumentFormatter

The main goal of Logahawk is to make it easy to log objects. By "log objects" I mean converting an object, more specifically any domain-specific custom-to-your-program object into a String that can be logged. This is accomplished via ArgumentFormatters. Logahawk comes with several ArgumentFormatters for common objects, and ArgumentFormatter is an interface so that new implementations can easily be created.

Example

For example, this code:

SimpleLogger logger = new SimpleLogger();
logger.getListenerContainer().add( new ConsoleListener() ); // output to System.out w/o timestamp
logger.info( new int[] { 16, 32, 64 } );
                
Outputs:
(INFO) Type: [I; ToString: [I@443226
                
Logahawk outputs the "toString()" of the given object when it cannot find an appropriate ArgumentFormatter. Its the best Logahawk can do, but its still not very good.

See the difference when we add an ArrayArgFormatter!

SimpleLogger logger = new SimpleLogger();
logger.getListenerContainer().add( new ConsoleListener() ); // output to System.out w/o timestamp
logger.getArgumentContainer().add( new ArrayArgFormatter() ); // !!! formats arrays
logger.getArgumentContainer().add( new PrimitiveArgFormatter() ); // !!! formats primitives (our integers)
logger.info( new int[] { 16, 32, 64 } );
                
Output:
(INFO) (3 items in collection)
    [ 0 ] 16
    [ 1 ] 32
    [ 2 ] 64
                
Much better!