mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-13 06:01:28 +00:00
Custom formatter support (and fixes) for CPLog.
- 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.
This commit is contained in:
+80
-52
@@ -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("<html><head><title></title>"+CPLogPopupStyle+"</head><body></body></html>");
|
||||
|
||||
|
||||
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) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* AppController.j
|
||||
* CPLogTest
|
||||
*
|
||||
* Created by Aparajita Fishman on September 3, 2010.
|
||||
*/
|
||||
|
||||
@import <Foundation/CPObject.j>
|
||||
|
||||
|
||||
@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
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Main cib file base name</key>
|
||||
<string>MainMenu.cib</string>
|
||||
<key>CPBundleName</key>
|
||||
<string>nib2cibAlignmentTest</string>
|
||||
<key>CPPrincipalClass</key>
|
||||
<string>CPApplication</string>
|
||||
</dict>
|
||||
</plist>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,219 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
|
||||
<data>
|
||||
<int key="IBDocument.SystemTarget">1060</int>
|
||||
<string key="IBDocument.SystemVersion">10F569</string>
|
||||
<string key="IBDocument.InterfaceBuilderVersion">788</string>
|
||||
<string key="IBDocument.AppKitVersion">1038.29</string>
|
||||
<string key="IBDocument.HIToolboxVersion">461.00</string>
|
||||
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
|
||||
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="NS.object.0">788</string>
|
||||
</object>
|
||||
<array class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<integer value="371"/>
|
||||
</array>
|
||||
<array key="IBDocument.PluginDependencies">
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</array>
|
||||
<dictionary class="NSMutableDictionary" key="IBDocument.Metadata"/>
|
||||
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
|
||||
<object class="NSCustomObject" id="1021">
|
||||
<string key="NSClassName">NSApplication</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="1014">
|
||||
<string key="NSClassName">FirstResponder</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="1050">
|
||||
<string key="NSClassName">NSApplication</string>
|
||||
</object>
|
||||
<object class="NSWindowTemplate" id="972006081">
|
||||
<int key="NSWindowStyleMask">15</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
<string key="NSWindowRect">{{408, 519}, {707, 446}}</string>
|
||||
<int key="NSWTFlags">1946157056</int>
|
||||
<string key="NSWindowTitle">CPLog Test</string>
|
||||
<string key="NSWindowClass">NSWindow</string>
|
||||
<nil key="NSViewClass"/>
|
||||
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
|
||||
<object class="NSView" key="NSWindowView" id="439893737">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">274</int>
|
||||
<array class="NSMutableArray" key="NSSubviews">
|
||||
<object class="NSTextField" id="379399619">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">301</int>
|
||||
<string key="NSFrame">{{332, 214}, {41, 17}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="905367325">
|
||||
<int key="NSCellFlags">68288064</int>
|
||||
<int key="NSCellFlags2">272630784</int>
|
||||
<string key="NSContents">Hello!</string>
|
||||
<object class="NSFont" key="NSSupport">
|
||||
<string key="NSName">LucidaGrande</string>
|
||||
<double key="NSSize">13</double>
|
||||
<int key="NSfFlags">1044</int>
|
||||
</object>
|
||||
<reference key="NSControlView" ref="379399619"/>
|
||||
<object class="NSColor" key="NSBackgroundColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlColor</string>
|
||||
<object class="NSColor" key="NSColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSColor" key="NSTextColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">controlTextColor</string>
|
||||
<object class="NSColor" key="NSColor">
|
||||
<int key="NSColorSpace">3</int>
|
||||
<bytes key="NSWhite">MAA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
<string key="NSFrameSize">{707, 446}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
|
||||
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
|
||||
</object>
|
||||
<object class="NSCustomObject" id="635946545">
|
||||
<string key="NSClassName">AppController</string>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<array class="NSMutableArray" key="connectionRecords">
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">delegate</string>
|
||||
<reference key="source" ref="1021"/>
|
||||
<reference key="destination" ref="635946545"/>
|
||||
</object>
|
||||
<int key="connectionID">451</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">theWindow</string>
|
||||
<reference key="source" ref="635946545"/>
|
||||
<reference key="destination" ref="972006081"/>
|
||||
</object>
|
||||
<int key="connectionID">1090</int>
|
||||
</object>
|
||||
</array>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<array key="orderedObjects">
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">0</int>
|
||||
<array key="object" id="0"/>
|
||||
<reference key="children" ref="1048"/>
|
||||
<nil key="parent"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-2</int>
|
||||
<reference key="object" ref="1021"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">File's Owner</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-1</int>
|
||||
<reference key="object" ref="1014"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">First Responder</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">-3</int>
|
||||
<reference key="object" ref="1050"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
<string key="objectName">Application</string>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">371</int>
|
||||
<reference key="object" ref="972006081"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="439893737"/>
|
||||
</array>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">372</int>
|
||||
<reference key="object" ref="439893737"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="379399619"/>
|
||||
</array>
|
||||
<reference key="parent" ref="972006081"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">450</int>
|
||||
<reference key="object" ref="635946545"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1337</int>
|
||||
<reference key="object" ref="379399619"/>
|
||||
<array class="NSMutableArray" key="children">
|
||||
<reference ref="905367325"/>
|
||||
</array>
|
||||
<reference key="parent" ref="439893737"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">1338</int>
|
||||
<reference key="object" ref="905367325"/>
|
||||
<reference key="parent" ref="379399619"/>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<dictionary class="NSMutableDictionary" key="flattenedProperties">
|
||||
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="1337.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="1338.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string key="371.IBEditorWindowLastContentRect">{{329, 481}, {707, 446}}</string>
|
||||
<string key="371.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<boolean value="YES" key="371.IBViewEditorWindowController.showingLayoutRectangles"/>
|
||||
<string key="371.IBWindowTemplateEditedContentRect">{{329, 481}, {707, 446}}</string>
|
||||
<integer value="1" key="371.NSWindowTemplate.visibleAtLaunch"/>
|
||||
<string key="371.editorWindowContentRectSynchronizationRect">{{33, 99}, {480, 360}}</string>
|
||||
<string key="372.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<array class="NSMutableArray" key="372.IBUserGuides"/>
|
||||
</dictionary>
|
||||
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
|
||||
<nil key="activeLocalization"/>
|
||||
<dictionary class="NSMutableDictionary" key="localizations"/>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">1338</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">AppController</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<string key="NS.key.0">theWindow</string>
|
||||
<string key="NS.object.0">NSWindow</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
<string key="NS.key.0">theWindow</string>
|
||||
<object class="IBToOneOutletInfo" key="NS.object.0">
|
||||
<string key="name">theWindow</string>
|
||||
<string key="candidateClassName">NSWindow</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBUserSource</string>
|
||||
<string key="minorKey"/>
|
||||
</object>
|
||||
</object>
|
||||
</array>
|
||||
</object>
|
||||
<int key="IBDocument.localizationMode">0</int>
|
||||
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
|
||||
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
|
||||
<string key="IBDocument.LastKnownRelativeProjectPath">../registration.xcodeproj</string>
|
||||
<int key="IBDocument.defaultPropertyAccessControl">3</int>
|
||||
</data>
|
||||
</archive>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
DIR=`dirname $0`
|
||||
|
||||
/usr/bin/env objj "$DIR/test.j"
|
||||
@@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
|
||||
<!--
|
||||
index-debug.html
|
||||
TableCibTest
|
||||
|
||||
Created by Francisco Tolmasky on July 5, 2009.
|
||||
Copyright 2009, 280 North, Inc. All rights reserved.
|
||||
-->
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
|
||||
|
||||
<title>CPLog Test</title>
|
||||
|
||||
<script type = "text/javascript">
|
||||
OBJJ_MAIN_FILE = "main.j";
|
||||
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
|
||||
</script>
|
||||
|
||||
<script src = "Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script>
|
||||
|
||||
<style type = "text/css">
|
||||
body{margin:0; padding:0;}
|
||||
#container {position: absolute; top:50%; left:50%;}
|
||||
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
|
||||
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
|
||||
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
|
||||
</style>
|
||||
|
||||
<!--[if lt IE 7]>
|
||||
<STYLE type="text/css">
|
||||
#container { position: relative; top: 50%; }
|
||||
#content { position: relative;}
|
||||
</STYLE>
|
||||
<![endif]-->
|
||||
|
||||
</head>
|
||||
|
||||
<body style="">
|
||||
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
|
||||
<script type = "text/javascript">
|
||||
document.write("<div id='container'><p id='content'>" +
|
||||
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
|
||||
"Loading CPLog Test...</p></div>");
|
||||
</script>
|
||||
|
||||
<noscript>
|
||||
<div id="container">
|
||||
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
|
||||
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
|
||||
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
|
||||
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
|
||||
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
|
||||
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
|
||||
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
|
||||
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
|
||||
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
|
||||
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</noscript>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns = "http://www.w3.org/1999/xhtml" xml:lang = "en" lang = "en">
|
||||
<!--
|
||||
index.html
|
||||
TableCibTest
|
||||
|
||||
Created by Francisco Tolmasky on July 5, 2009.
|
||||
Copyright 2009, 280 North, Inc. All rights reserved.
|
||||
-->
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
|
||||
|
||||
<title>CPLog Test</title>
|
||||
|
||||
<script type = "text/javascript">
|
||||
OBJJ_MAIN_FILE = "main.j";
|
||||
</script>
|
||||
|
||||
<script src = "Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script>
|
||||
|
||||
<style type = "text/css">
|
||||
body{margin:0; padding:0;}
|
||||
#container {position: absolute; top:50%; left:50%;}
|
||||
#content {width:800px; text-align:center; margin-left: -400px; height:50px; margin-top:-25px; line-height: 50px;}
|
||||
#content {font-family: "Helvetica", "Arial", sans-serif; font-size: 18px; color: black; text-shadow: 0px 1px 0px white; }
|
||||
#loadgraphic {margin-right: 0.2em; margin-bottom:-2px;}
|
||||
</style>
|
||||
|
||||
<!--[if lt IE 7]>
|
||||
<STYLE type="text/css">
|
||||
#container { position: relative; top: 50%; }
|
||||
#content { position: relative;}
|
||||
</STYLE>
|
||||
<![endif]-->
|
||||
|
||||
</head>
|
||||
|
||||
<body style="">
|
||||
<div id="loadingcontainer" style=" background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
|
||||
<script type = "text/javascript">
|
||||
document.write("<div id='container'><p id='content'>" +
|
||||
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
|
||||
"Loading CPLog Test...</p></div>");
|
||||
</script>
|
||||
|
||||
<noscript>
|
||||
<div id="container">
|
||||
<div style="width: 440px; padding: 10px 25px 20px 25px; font-family: sans-serif; background-color: #ffffff; position: relative; left: -245px; top: -120px; text-align: center; -moz-border-radius: 20px; -webkit-border-radius: 20px; color: #555555">
|
||||
<p style="line-height: 1.4em;">JavaScript is required for this site to work correctly but is either disabled or not supported by your browser.</p>
|
||||
<p style="font-size:120%; padding:10px;"><a href="http://cappuccino.org/noscript">Show me how to enable JavaScript</a></p>
|
||||
<p style="font-size:80%;">You may want to upgrade to a newer browser while you're at it:</p>
|
||||
<ul style="margin:0;padding:0; text-align: center; font-size:80%;" >
|
||||
<li style="display: inline;"><a href="http://www.apple.com/safari/download/">Safari</a></li>
|
||||
<li style="display: inline;"><a href="http://www.mozilla.com/en-US/firefox/">Firefox</a></li>
|
||||
<li style="display: inline;"><a href="http://www.google.com/chrome/">Chrome</a></li>
|
||||
<li style="display: inline;"><a href="http://www.opera.com/download/">Opera</a></li>
|
||||
<li style="display: inline;"><a href="http://www.microsoft.com/windows/downloads/ie/getitnow.mspx">Internet Explorer</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</noscript>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
Executable
+37
@@ -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");
|
||||
}
|
||||
Reference in New Issue
Block a user