public
Description: Web Application Framework in JavaScript and Objective-J
Home | Edit | New

CPLog

Description

CPLog consists of a generic logging facility along with logging “providers” for browsers as well as command line tools.

Log Levels

The log levels are (in order): “fatal”, “error”, “warn”, “info”, “debug”, “trace”

Log Providers

  • CPLogPopup – For browsers, pops up an interactive log display with numerous options. This is the recommended provider for browsers.
  • CPLogConsole – For browsers with a window.console object (Firefox, Safari, Chrome, Opera?), prints to console.error, console.warn, etc.
  • CPLogAlert – For browsers, brings up an alert (blocking execution). Allows you to cancel all future CPLogAlerts until reloading application.
    *CPLogPrint – For command line applications, prints to stdout. Currently colorizes the logs (red for “fatal”, yellow for “error”, etc)

Registering log providers

To register a logging provider, call one of the following functions

  • CPLogRegister(aProvider, aMaxLevel) // registers for log levels up to a max level (passed in as a string) or all log levels if no max is provided.
  • CPLogRegisterRange(aProvider, aMinLevel, aMaxLevel) // registers for for a range of log levels (passed in as strings)
  • CPLogRegisterSingle(aProvider, aLevel) // registers for a single log level

For example, to register CPLogPopup for all log levels:

CPLogRegister(CPLogPopup);

Writing your own provider

The interface for log providers is very simple: CPLogPrint(aMessage, aLevel, aTitle)

Last edited by tlrobinson, Thu Sep 04 22:51:15 -0700 2008
Home | Edit | New
Versions: