< documentation

logger 1.0.x

usage

Retrieves or creates a category logger. This plugin provides an efficient logging implementation that allows application components to log messages at 5 levels to a hierarchical category that can be tuned via app/configs/logging.js

options

creating

Loggers are created by simply defining their category.
category String
A dot-delimited name, usually the namespace of the class the logger is being used in.

using

All logger methods are chainable and use a sprintf style argument pattern. This mean the first arg is a string like "The %s fox jumped over the %s brown dog." and the remainder of the arguments are used to replace the %s in the string.
argument[0] String
A sprintf style string used as the template for the logging message: eg "a+b=%s"
argument[1..n] Any
All remaining arguments are used to replace the %s values in the message template.

examples

The logger is returned if any category configured in app/configs/logging.js matches, including the catch-all root category, otherwise a safe, efficient, chainable NullLogger instance is returned.

var log = $.logger("MyApp.Controller.HelloController");
log.debug("this is a %s message", 'debug').
    info("this is a %s message", 'info').
    warn("this is a %s message", 'warn').
    error("this is a %s message", 'error').
    exception(e);
            

Note that logging methods are chainable.

Creating Loggers as Closure Objects

It doesnt take much, just decide on the category name, and call $.logger.

(function($, $C)&#x7B;
    //private static logger used across all instances
    var log;

    $C.Hello = function(options)&#x7B;
       //initialize the instance
       $.extend(true, this, options);
       //initalize the logger
       log = log||$.logger('MyApp.Controllers.Hello');
    };

    $.extend($C.Hello.prototype,&#x7B;
        sayHello: function(name)&#x7B;
          log.debug("Saying hello to %s", name);
        }
    });
    
})(jQuery, MyApp.Controllers);

        
logger releases

Project

Guides

This guide is applicable to both the jquery-claypool client and server application frameworks. Where the two differ functionally the documentation will provide notes and examples of usage in each environment.