mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-26 21:47:04 +00:00
- A formatter function can be passed to the CPLogRegister functions. If the given level already has a provider for the given level, the formatter will be replaced with the one passed to the register function. - Added CPLogColorize function to make it easy for users to colorize messages. - CPLogRegisterRange now checks for min <= max, and now correctly starts iterating from min. - Moved colorization of log level to _CPFormatLogMessage. - Whitespace cleanup.
38 lines
973 B
Plaintext
Executable File
38 lines
973 B
Plaintext
Executable File
/*
|
|
* test.j
|
|
* CPLogTest
|
|
*
|
|
* Created by Aparajita Fishman on September 3, 2010.
|
|
*/
|
|
|
|
function formatter(aString, aLevel, aTitle)
|
|
{
|
|
return aString;
|
|
}
|
|
|
|
function debugFormatter(aString, aLevel, aTitle)
|
|
{
|
|
return CPLogColorize(aString, aLevel);
|
|
}
|
|
|
|
function warningFormatter(aString, aLevel, aTitle)
|
|
{
|
|
return "[" + aLevel + "] " + aString;
|
|
}
|
|
|
|
function main(args)
|
|
{
|
|
CPLogRegister(CPLogPrint, null, formatter);
|
|
CPLogRegisterRange(CPLogPrint, "trace", "trace");
|
|
CPLogRegisterRange(CPLogPrint, "debug", "debug", debugFormatter);
|
|
CPLogRegisterRange(CPLogPrint, "fatal", "warn", warningFormatter);
|
|
|
|
CPLog.fatal("I have to go now...");
|
|
CPLog.error("Doh! An error occurred");
|
|
CPLog.warn("Danger, Will Robinson! Danger!");
|
|
CPLog.info("For your information, you can now provide your own formatter");
|
|
CPLog.debug("A colorized debug message");
|
|
CPLog.trace("Using the default CPLog formatter");
|
|
CPLog("The default logging level");
|
|
}
|