mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-27 14:07:03 +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.
37 lines
783 B
Plaintext
Executable File
37 lines
783 B
Plaintext
Executable File
/*
|
|
* AppController.j
|
|
* CPLogTest
|
|
*
|
|
* Created by Aparajita Fishman on September 3, 2010.
|
|
*/
|
|
|
|
@import <Foundation/Foundation.j>
|
|
@import <AppKit/AppKit.j>
|
|
|
|
@import "AppController.j"
|
|
|
|
function formatter(aString, aLevel, aTitle)
|
|
{
|
|
return aString;
|
|
}
|
|
|
|
function fancyFormatter(aString, aLevel, aTitle)
|
|
{
|
|
return aTitle + ": [" + aLevel + "] " + CPLogColorize(aString, aLevel);
|
|
}
|
|
|
|
function warningFormatter(aString, aLevel, aTitle)
|
|
{
|
|
return aString + " (you have been warned!)";
|
|
}
|
|
|
|
function main(args, namedArgs)
|
|
{
|
|
CPLogRegister(CPLogPopup, "info");
|
|
CPLogRegister(CPLogConsole, null, formatter);
|
|
CPLogRegisterRange(CPLogConsole, "trace", "trace");
|
|
CPLogRegisterRange(CPLogConsole, "fatal", "warn", warningFormatter);
|
|
|
|
CPApplicationMain(args, namedArgs);
|
|
}
|