diff --git a/Objective-J/CPLog.js b/Objective-J/CPLog.js index 473ccfd88..dec1e0f06 100644 --- a/Objective-J/CPLog.js +++ b/Objective-J/CPLog.js @@ -36,40 +36,43 @@ var _CPLogRegistrations = {}; // Register Functions: // Register a logger for all levels, or up to an optional max level -GLOBAL(CPLogRegister) = function(aProvider, aMaxLevel) +GLOBAL(CPLogRegister) = function(aProvider, aMaxLevel, aFormatter) { - CPLogRegisterRange(aProvider, CPLogLevels[0], aMaxLevel || CPLogLevels[CPLogLevels.length-1]); + CPLogRegisterRange(aProvider, CPLogLevels[0], aMaxLevel || CPLogLevels[CPLogLevels.length-1], aFormatter); } // Register a logger for a range of levels -GLOBAL(CPLogRegisterRange) = function(aProvider, aMinLevel, aMaxLevel) +GLOBAL(CPLogRegisterRange) = function(aProvider, aMinLevel, aMaxLevel, aFormatter) { var min = _CPLogLevelsInverted[aMinLevel]; var max = _CPLogLevelsInverted[aMaxLevel]; - if (min !== undefined && max !== undefined) - for (var i = 0; i <= max; i++) - CPLogRegisterSingle(aProvider, CPLogLevels[i]); + if (min !== undefined && max !== undefined && min <= max) + for (var i = min; i <= max; i++) + CPLogRegisterSingle(aProvider, CPLogLevels[i], aFormatter); } // Register a logger for a single level -GLOBAL(CPLogRegisterSingle) = function(aProvider, aLevel) +GLOBAL(CPLogRegisterSingle) = function(aProvider, aLevel, aFormatter) { if (!_CPLogRegistrations[aLevel]) _CPLogRegistrations[aLevel] = []; - // prevent duplicate registrations + // prevent duplicate registrations, but change formatter for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++) - if (_CPLogRegistrations[aLevel][i] === aProvider) + if (_CPLogRegistrations[aLevel][i][0] === aProvider) + { + _CPLogRegistrations[aLevel][i][1] = aFormatter; return; + } - _CPLogRegistrations[aLevel].push(aProvider); + _CPLogRegistrations[aLevel].push([aProvider, aFormatter]); } GLOBAL(CPLogUnregister) = function(aProvider) { for (var aLevel in _CPLogRegistrations) for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++) - if (_CPLogRegistrations[aLevel][i] === aProvider) + if (_CPLogRegistrations[aLevel][i][0] === aProvider) _CPLogRegistrations[aLevel].splice(i--, 1); // decrement since we're removing an element } @@ -80,13 +83,16 @@ function _CPLogDispatch(parameters, aLevel, aTitle) aTitle = CPLogDefaultTitle; if (aLevel == undefined) aLevel = CPLogDefaultLevel; - + // use sprintf if param 0 is a string and there is more than one param. otherwise just convert param 0 to a string var message = (typeof parameters[0] == "string" && parameters.length > 1) ? exports.sprintf.apply(null, parameters) : String(parameters[0]); - + if (_CPLogRegistrations[aLevel]) for (var i = 0; i < _CPLogRegistrations[aLevel].length; i++) - _CPLogRegistrations[aLevel][i](message, aLevel, aTitle); + { + var logger = _CPLogRegistrations[aLevel][i]; + logger[0](message, aLevel, aTitle, logger[1]); + } } // Setup CPLog() and CPLog.xxx() aliases @@ -101,7 +107,7 @@ for (var i = 0; i < CPLogLevels.length; i++) var _CPFormatLogMessage = function(aString, aLevel, aTitle) { var now = new Date(); - aLevel = ( aLevel == null ? '' : ' [' + aLevel + ']' ); + aLevel = ( aLevel == null ? '' : ' [' + CPLogColorize(aLevel, aLevel) + ']' ); if (typeof exports.sprintf == "function") return exports.sprintf("%4d-%02d-%02d %02d:%02d:%02d.%03d %s%s: %s", @@ -115,12 +121,12 @@ var _CPFormatLogMessage = function(aString, aLevel, aTitle) // Loggers: // CPLogConsole uses the built in "console" object -GLOBAL(CPLogConsole) = function(aString, aLevel, aTitle) +GLOBAL(CPLogConsole) = function(aString, aLevel, aTitle, aFormatter) { if (typeof console != "undefined") { - var message = _CPFormatLogMessage(aString, aLevel, aTitle); - + var message = (aFormatter || _CPFormatLogMessage)(aString, aLevel, aTitle); + var logger = { "fatal": "error", "error": "error", @@ -129,7 +135,7 @@ GLOBAL(CPLogConsole) = function(aString, aLevel, aTitle) "debug": "debug", "trace": "debug" }[aLevel]; - + if (logger && console[logger]) console[logger](message); else if (console.log) @@ -158,7 +164,21 @@ try { var stream; -GLOBAL(CPLogPrint) = function(aString, aLevel, aTitle) +GLOBAL(CPLogColorize) = function(aString, aLevel) +{ + if (stream) + { + // Try to determine if a colorizing stanza is already open, they can't be nested + if (/^.*\x00\w+\([^\x00]*$/.test(aString)) + return aString; + else + return "\0" + (levelColorMap[aLevel] || "info") + "(" + aString + "\0)"; + } + else + return aString; +} + +GLOBAL(CPLogPrint) = function(aString, aLevel, aTitle, aFormatter) { if (stream === undefined) { try { @@ -168,56 +188,64 @@ GLOBAL(CPLogPrint) = function(aString, aLevel, aTitle) } } + var formatter = aFormatter || _CPFormatLogMessage; + if (stream) { if (aLevel == "fatal" || aLevel == "error" || aLevel == "warn") - stream.print("\0"+levelColorMap[aLevel]+"(" + _CPFormatLogMessage(aString, aLevel, aTitle) + "\0)"); + stream.print(CPLogColorize(formatter(aString, aLevel, aTitle), aLevel)); else - stream.print(_CPFormatLogMessage(aString, "\0"+levelColorMap[aLevel]+"(" + aLevel + "\0)", aTitle)); + stream.print(formatter(aString, aLevel, aTitle)); } else if (typeof print != "undefined") { - print(_CPFormatLogMessage(aString, aLevel, aTitle)) + print(formatter(aString, aLevel, aTitle)) } } #else +// A stub to allow the same formatter to be used for both stream and browser output +GLOBAL(CPLogColorize) = function(aString, aLevel) +{ + return aString; +} + // CPLogAlert uses basic browser alert() functions -GLOBAL(CPLogAlert) = function(aString, aLevel, aTitle) +GLOBAL(CPLogAlert) = function(aString, aLevel, aTitle, aFormatter) { if (typeof alert != "undefined" && !CPLogDisable) { - var message = _CPFormatLogMessage(aString, aLevel, aTitle); + var message = (aFormatter || _CPFormatLogMessage)(aString, aLevel, aTitle); CPLogDisable = !confirm(message + "\n\n(Click cancel to stop log alerts)"); } } // CPLogPopup uses a slick popup window in the browser: var CPLogWindow = null; -GLOBAL(CPLogPopup) = function(aString, aLevel, aTitle) +GLOBAL(CPLogPopup) = function(aString, aLevel, aTitle, aFormatter) { try { if (CPLogDisable || window.open == undefined) return; - + if (!CPLogWindow || !CPLogWindow.document) { CPLogWindow = window.open("", "_blank", "width=600,height=400,status=no,resizable=yes,scrollbars=yes"); - + if (!CPLogWindow) { CPLogDisable = !confirm(aString + "\n\n(Disable pop-up blocking for CPLog window; Click cancel to stop log alerts)"); return; } - + _CPLogInitPopup(CPLogWindow); } - + var logDiv = CPLogWindow.document.createElement("div"); logDiv.setAttribute("class", aLevel || "fatal"); - var message = _CPFormatLogMessage(aString, null, aTitle); - + var message = (aFormatter || _CPFormatLogMessage)(aString, aFormatter ? aLevel : null, aTitle); + logDiv.appendChild(CPLogWindow.document.createTextNode(message)); CPLogWindow.log.appendChild(logDiv); - + if (CPLogWindow.focusEnabled.checked) CPLogWindow.focus(); if (CPLogWindow.blockEnabled.checked) @@ -251,27 +279,27 @@ ul#options li{margin:0 0 0 0;padding:0 0 0 0;display:inline;} \ function _CPLogInitPopup(logWindow) { var doc = logWindow.document; - + // HACK so that head is available below: doc.writeln(""+CPLogPopupStyle+""); - + doc.title = CPLogDefaultTitle + " Run Log"; - + var head = doc.getElementsByTagName("head")[0]; var body = doc.getElementsByTagName("body")[0]; - + var base = window.location.protocol + "//" + window.location.host + window.location.pathname; base = base.substring(0,base.lastIndexOf("/")+1); - + var div = doc.createElement("div"); div.setAttribute("id", "header"); body.appendChild(div); - + // Enablers var ul = doc.createElement("ul"); ul.setAttribute("id", "enablers"); div.appendChild(ul); - + for (var i = 0; i < CPLogLevels.length; i++) { var li = doc.createElement("li"); li.setAttribute("id", "en"+CPLogLevels[i]); @@ -281,35 +309,35 @@ function _CPLogInitPopup(logWindow) li.appendChild(doc.createTextNode(CPLogLevels[i])); ul.appendChild(li); } - + // Options var ul = doc.createElement("ul"); ul.setAttribute("id", "options"); div.appendChild(ul); - + var options = {"focus":["Focus",false], "block":["Block",false], "wrap":["Wrap",false], "scroll":["Scroll",true], "close":["Close",true]}; for (o in options) { var li = doc.createElement("li"); ul.appendChild(li); - + logWindow[o+"Enabled"] = doc.createElement("input"); logWindow[o+"Enabled"].setAttribute("id", o); logWindow[o+"Enabled"].setAttribute("type", "checkbox"); - if (options[o][1]) + if (options[o][1]) logWindow[o+"Enabled"].setAttribute("checked", "checked"); li.appendChild(logWindow[o+"Enabled"]); - + var label = doc.createElement("label"); label.setAttribute("for", o); label.appendChild(doc.createTextNode(options[o][0])); li.appendChild(label); } - + // Log logWindow.log = doc.createElement("div"); logWindow.log.setAttribute("class", "enerror endebug enwarn eninfo enfatal entrace"); body.appendChild(logWindow.log); - + logWindow.toggle = function(elem) { var enabled = (elem.getAttribute("enabled") == "yes") ? "no" : "yes"; elem.setAttribute("enabled", enabled); @@ -319,17 +347,17 @@ function _CPLogInitPopup(logWindow) else logWindow.log.className = logWindow.log.className.replace(new RegExp("[\\s]*"+elem.id, "g"), ""); } - + // Scroll logWindow.scrollToBottom = function() { logWindow.scrollTo(0, body.offsetHeight); } - + // Wrap logWindow.wrapEnabled.addEventListener("click", function() { logWindow.log.setAttribute("wrap", logWindow.wrapEnabled.checked ? "yes" : "no"); }, false); - + // Clear logWindow.addEventListener("keydown", function(e) { var e = e || logWindow.event; @@ -340,7 +368,7 @@ function _CPLogInitPopup(logWindow) e.preventDefault(); } }, "false"); - + // Parent closing window.addEventListener("unload", function() { if (logWindow && logWindow.closeEnabled && logWindow.closeEnabled.checked) { @@ -348,7 +376,7 @@ function _CPLogInitPopup(logWindow) logWindow.close(); } }, false); - + // Log popup closing logWindow.addEventListener("unload", function() { if (!CPLogDisable) { diff --git a/Tests/Manual/CPLogTest/AppController.j b/Tests/Manual/CPLogTest/AppController.j new file mode 100644 index 000000000..5a686f700 --- /dev/null +++ b/Tests/Manual/CPLogTest/AppController.j @@ -0,0 +1,32 @@ +/* + * AppController.j + * CPLogTest + * + * Created by Aparajita Fishman on September 3, 2010. + */ + +@import + + +@implementation AppController : CPObject +{ + CPWindow theWindow; +} + +- (void)awakeFromCib +{ + [theWindow setFullPlatformWindow:YES]; +} + +- (void)applicationDidFinishLaunching:(CPNotification)aNotification +{ + CPLog.fatal("fatal"); + CPLog.error("error"); + CPLog.warn("warn"); + CPLog.info("info"); + CPLog.debug("debug"); + CPLog.trace("trace"); + CPLog("message"); +} + +@end diff --git a/Tests/Manual/CPLogTest/Info.plist b/Tests/Manual/CPLogTest/Info.plist new file mode 100644 index 000000000..2a86dc894 --- /dev/null +++ b/Tests/Manual/CPLogTest/Info.plist @@ -0,0 +1,12 @@ + + + + + Main cib file base name + MainMenu.cib + CPBundleName + nib2cibAlignmentTest + CPPrincipalClass + CPApplication + + diff --git a/Tests/Manual/CPLogTest/Resources/MainMenu.cib b/Tests/Manual/CPLogTest/Resources/MainMenu.cib new file mode 100644 index 000000000..f780ae1fb --- /dev/null +++ b/Tests/Manual/CPLogTest/Resources/MainMenu.cib @@ -0,0 +1 @@ +280NPLIST;1.0;D;K;4;$topD;K;18;CPCibObjectDataKeyD;K;6;CP$UIDd;1;2E;E;K;8;$objectsA;S;5;$nullD;K;10;$classnameS;16;_CPCibObjectDataK;8;$classesA;S;16;_CPCibObjectDataS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;1E;K;28;_CPCibObjectDataNamesKeysKeyD;K;6;CP$UIDd;1;4E;K;30;_CPCibObjectDataNamesValuesKeyD;K;6;CP$UIDd;1;5E;K;30;_CPCibObjectDataClassesKeysKeyD;K;6;CP$UIDd;1;6E;K;32;_CPCibObjectDataClassesValuesKeyD;K;6;CP$UIDd;1;7E;K;30;_CPCibObjectDataConnectionsKeyD;K;6;CP$UIDd;1;8E;K;28;_CPCibObjectDataFrameworkKeyD;K;6;CP$UIDd;1;9E;K;26;_CPCibObjectDataNextOidKeyD;K;6;CP$UIDd;2;10E;K;30;_CPCibObjectDataObjectsKeysKeyD;K;6;CP$UIDd;2;11E;K;32;_CPCibObjectDataObjectsValuesKeyD;K;6;CP$UIDd;2;12E;K;26;_CPCibObjectDataOidKeysKeyD;K;6;CP$UIDd;2;13E;K;28;_CPCibObjectDataOidValuesKeyD;K;6;CP$UIDd;2;14E;K;28;_CPCibObjectDataFileOwnerKeyD;K;6;CP$UIDd;2;16E;K;33;_CPCibObjectDataVisibleWindowsKeyD;K;6;CP$UIDd;2;18E;E;D;K;10;$classnameS;7;CPArrayK;8;$classesA;S;7;CPArrayS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;19E;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;22E;D;K;6;CP$UIDd;2;24E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;26E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;27E;D;K;6;CP$UIDd;2;28E;D;K;6;CP$UIDd;2;29E;D;K;6;CP$UIDd;2;30E;D;K;6;CP$UIDd;2;31E;D;K;6;CP$UIDd;2;32E;D;K;6;CP$UIDd;2;33E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;35E;D;K;6;CP$UIDd;2;36E;E;E;S;16;IBCocoaFrameworkD;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;22E;D;K;6;CP$UIDd;2;26E;D;K;6;CP$UIDd;2;24E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;1;0E;D;K;6;CP$UIDd;2;19E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;2;16E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;26E;D;K;6;CP$UIDd;2;24E;D;K;6;CP$UIDd;2;16E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;10;$classnameS;18;_CPCibCustomObjectK;8;$classesA;S;18;_CPCibCustomObjectS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;15E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;37E;E;D;K;10;$classnameS;5;CPSetK;8;$classesA;S;5;CPSetS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;17E;K;15;CPSetObjectsKeyD;K;6;CP$UIDd;2;38E;E;D;K;6;$classD;K;6;CP$UIDd;2;15E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;39E;E;D;K;10;$classnameS;6;CPViewK;8;$classesA;S;6;CPViewS;11;CPResponderS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;20E;K;14;CPViewFrameKeyD;K;6;CP$UIDd;2;40E;K;15;CPViewBoundsKeyD;K;6;CP$UIDd;2;40E;K;17;CPViewSubviewsKeyD;K;6;CP$UIDd;2;41E;K;22;CPViewAutoresizingMaskD;K;6;CP$UIDd;2;42E;K;19;CPViewThemeStateKeyD;K;6;CP$UIDd;2;43E;E;D;K;6;$classD;K;6;CP$UIDd;2;15E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;37E;E;D;K;10;$classnameS;11;CPTextFieldK;8;$classesA;S;11;CPTextFieldS;9;CPControlS;6;CPViewS;11;CPResponderS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;23E;K;27;CPResponderNextResponderKeyD;K;6;CP$UIDd;2;21E;K;14;CPViewFrameKeyD;K;6;CP$UIDd;2;44E;K;15;CPViewBoundsKeyD;K;6;CP$UIDd;2;45E;K;18;CPViewSuperviewKeyD;K;6;CP$UIDd;2;21E;K;22;CPViewAutoresizingMaskD;K;6;CP$UIDd;2;46E;K;19;CPViewThemeStateKeyD;K;6;CP$UIDd;2;43E;K;17;$aline-break-modeD;K;6;CP$UIDd;2;47E;K;11;$aalignmentD;K;6;CP$UIDd;2;48E;K;17;CPControlValueKeyD;K;6;CP$UIDd;2;49E;K;24;CPControlSendActionOnKeyD;K;6;CP$UIDd;2;50E;K;24;CPTextFieldIsEditableKeyD;K;6;CP$UIDd;2;51E;K;26;CPTextFieldIsSelectableKeyD;K;6;CP$UIDd;2;51E;K;29;CPTextFieldDrawsBackgroundKeyD;K;6;CP$UIDd;1;0E;K;29;CPTextFieldBackgroundColorKeyD;K;6;CP$UIDd;1;0E;K;27;CPTextFieldLineBreakModeKeyD;K;6;CP$UIDd;2;47E;K;23;CPTextFieldAlignmentKeyD;K;6;CP$UIDd;2;48E;K;31;CPTextFieldPlaceholderStringKeyD;K;6;CP$UIDd;1;0E;E;D;K;10;$classnameS;20;_CPCibWindowTemplateK;8;$classesA;S;20;_CPCibWindowTemplateS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;25E;K;30;_CPCibWindowTemplateMaxSizeKeyD;K;6;CP$UIDd;2;52E;K;32;_CPCibWindowTemplateViewClassKeyD;K;6;CP$UIDd;1;0E;K;34;_CPCibWindowTemplateWindowClassKeyD;K;6;CP$UIDd;2;53E;K;33;_CPCibWindowTemplateWindowRectKeyD;K;6;CP$UIDd;2;54E;K;30;_CPCibWindowTempatStyleMaskKeyD;K;6;CP$UIDd;2;55E;K;34;_CPCibWindowTemplateWindowTitleKeyD;K;6;CP$UIDd;2;56E;K;33;_CPCibWindowTemplateWindowViewKeyD;K;6;CP$UIDd;2;21E;E;S;14;App ControllerS;12;File's OwnerS;12;Content ViewS;11;ApplicationS;20;Static Text (Hello!)S;24;Text Field Cell (Hello!)S;19;Window (CPLog Test)D;K;10;$classnameS;20;CPCibOutletConnectorK;8;$classesA;S;20;CPCibOutletConnectorS;14;CPCibConnectorS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;34E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;16E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;19E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;57E;E;D;K;6;$classD;K;6;CP$UIDd;2;34E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;19E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;26E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;58E;E;S;13;CPApplicationD;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;26E;E;E;S;13;AppControllerS;20;{{0, 0}, {707, 446}}D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;24E;E;E;d;2;18S;6;normalS;22;{{331, 211}, {43, 25}}S;18;{{0, 0}, {43, 25}}d;2;45d;1;2d;1;4S;6;Hello!d;4;3072F;S;28;{1.79769e+308, 1.79769e+308}S;8;CPWindowS;23;{{408, 63}, {707, 446}}d;2;15S;10;CPLog TestS;8;delegateS;9;theWindowE;K;9;$archiverS;15;CPKeyedArchiverK;8;$versionS;6;100000E; \ No newline at end of file diff --git a/Tests/Manual/CPLogTest/Resources/MainMenu.xib b/Tests/Manual/CPLogTest/Resources/MainMenu.xib new file mode 100644 index 000000000..1bc94c31e --- /dev/null +++ b/Tests/Manual/CPLogTest/Resources/MainMenu.xib @@ -0,0 +1,219 @@ + + + + 1060 + 10F569 + 788 + 1038.29 + 461.00 + + com.apple.InterfaceBuilder.CocoaPlugin + 788 + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + + + + + NSApplication + + + FirstResponder + + + NSApplication + + + 15 + 2 + {{408, 519}, {707, 446}} + 1946157056 + CPLog Test + NSWindow + + {1.79769e+308, 1.79769e+308} + + + 274 + + + + 301 + {{332, 214}, {41, 17}} + + YES + + 68288064 + 272630784 + Hello! + + LucidaGrande + 13 + 1044 + + + + 6 + System + controlColor + + 3 + MC42NjY2NjY2NjY3AA + + + + 6 + System + controlTextColor + + 3 + MAA + + + + + + {707, 446} + + + {{0, 0}, {1680, 1028}} + {1.79769e+308, 1.79769e+308} + + + AppController + + + + + + + delegate + + + + 451 + + + + theWindow + + + + 1090 + + + + + + 0 + + + + + + -2 + + + File's Owner + + + -1 + + + First Responder + + + -3 + + + Application + + + 371 + + + + + + + + 372 + + + + + + + + 450 + + + + + 1337 + + + + + + + + 1338 + + + + + + + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + {{329, 481}, {707, 446}} + com.apple.InterfaceBuilder.CocoaPlugin + + {{329, 481}, {707, 446}} + + {{33, 99}, {480, 360}} + com.apple.InterfaceBuilder.CocoaPlugin + + + + + + + 1338 + + + + + AppController + NSObject + + theWindow + NSWindow + + + theWindow + + theWindow + NSWindow + + + + IBUserSource + + + + + + 0 + IBCocoaFramework + YES + ../registration.xcodeproj + 3 + + diff --git a/Tests/Manual/CPLogTest/Resources/spinner.gif b/Tests/Manual/CPLogTest/Resources/spinner.gif new file mode 100644 index 000000000..06dbc2bc2 Binary files /dev/null and b/Tests/Manual/CPLogTest/Resources/spinner.gif differ diff --git a/Tests/Manual/CPLogTest/execute_me b/Tests/Manual/CPLogTest/execute_me new file mode 100755 index 000000000..d100ff518 --- /dev/null +++ b/Tests/Manual/CPLogTest/execute_me @@ -0,0 +1,5 @@ +#!/bin/sh + +DIR=`dirname $0` + +/usr/bin/env objj "$DIR/test.j" diff --git a/Tests/Manual/CPLogTest/index-debug.html b/Tests/Manual/CPLogTest/index-debug.html new file mode 100644 index 000000000..1b13a2b2b --- /dev/null +++ b/Tests/Manual/CPLogTest/index-debug.html @@ -0,0 +1,69 @@ + + + + + + + + CPLog Test + + + + + + + + + + + + +
+ + + +
+ + + diff --git a/Tests/Manual/CPLogTest/index.html b/Tests/Manual/CPLogTest/index.html new file mode 100644 index 000000000..220bc9a8e --- /dev/null +++ b/Tests/Manual/CPLogTest/index.html @@ -0,0 +1,68 @@ + + + + + + + + CPLog Test + + + + + + + + + + + + +
+ + + +
+ + + diff --git a/Tests/Manual/CPLogTest/main.j b/Tests/Manual/CPLogTest/main.j new file mode 100755 index 000000000..8355f4ec5 --- /dev/null +++ b/Tests/Manual/CPLogTest/main.j @@ -0,0 +1,36 @@ +/* + * AppController.j + * CPLogTest + * + * Created by Aparajita Fishman on September 3, 2010. + */ + +@import +@import + +@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); +} diff --git a/Tests/Manual/CPLogTest/test.j b/Tests/Manual/CPLogTest/test.j new file mode 100755 index 000000000..ae67a3617 --- /dev/null +++ b/Tests/Manual/CPLogTest/test.j @@ -0,0 +1,37 @@ +/* + * 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"); +}