mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-11-06 10:33:00 +00:00
Add more colour to command line output
This commit is contained in:
@@ -300,8 +300,8 @@ Command.prototype.execute = function() {
|
|||||||
pathprefix: pathprefix
|
pathprefix: pathprefix
|
||||||
});
|
});
|
||||||
this.server.listen(port,host);
|
this.server.listen(port,host);
|
||||||
console.log("Serving on " + host + ":" + port);
|
$tw.utils.log("Serving on " + host + ":" + port,"brown/orange");
|
||||||
console.log("(press ctrl-C to exit)");
|
$tw.utils.log("(press ctrl-C to exit)","red");
|
||||||
// Warn if required plugins are missing
|
// Warn if required plugins are missing
|
||||||
if(!$tw.wiki.getTiddler("$:/plugins/tiddlywiki/tiddlyweb") || !$tw.wiki.getTiddler("$:/plugins/tiddlywiki/filesystem")) {
|
if(!$tw.wiki.getTiddler("$:/plugins/tiddlywiki/tiddlyweb") || !$tw.wiki.getTiddler("$:/plugins/tiddlywiki/filesystem")) {
|
||||||
$tw.utils.warning("Warning: Plugins required for client-server operation (\"tiddlywiki/filesystem\" and \"tiddlywiki/tiddlyweb\") are missing from tiddlywiki.info file");
|
$tw.utils.warning("Warning: Plugins required for client-server operation (\"tiddlywiki/filesystem\" and \"tiddlywiki/tiddlyweb\") are missing from tiddlywiki.info file");
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ function Syncer(options) {
|
|||||||
this.fallbackInterval = options.fallbackInterval || this.fallbackInterval;
|
this.fallbackInterval = options.fallbackInterval || this.fallbackInterval;
|
||||||
this.pollTimerInterval = options.pollTimerInterval || this.pollTimerInterval;
|
this.pollTimerInterval = options.pollTimerInterval || this.pollTimerInterval;
|
||||||
// Make a logger
|
// Make a logger
|
||||||
this.logger = new $tw.utils.Logger("syncer" + ($tw.browser ? "-browser" : "") + ($tw.node ? "-server" : "") + (this.syncadaptor.name ? ("-" + this.syncadaptor.name) : ""));
|
this.logger = new $tw.utils.Logger("syncer" + ($tw.browser ? "-browser" : "") + ($tw.node ? "-server" : "") + (this.syncadaptor.name ? ("-" + this.syncadaptor.name) : ""),{colour: "cyan"});
|
||||||
// Compile the dirty tiddler filter
|
// Compile the dirty tiddler filter
|
||||||
this.filterFn = this.wiki.compileFilter(this.wiki.getTiddlerText(this.titleSyncFilter));
|
this.filterFn = this.wiki.compileFilter(this.wiki.getTiddlerText(this.titleSyncFilter));
|
||||||
// Record information for known tiddlers
|
// Record information for known tiddlers
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ var ALERT_TAG = "$:/tags/Alert";
|
|||||||
/*
|
/*
|
||||||
Make a new logger
|
Make a new logger
|
||||||
*/
|
*/
|
||||||
function Logger(componentName) {
|
function Logger(componentName,options) {
|
||||||
|
options = options || {};
|
||||||
this.componentName = componentName || "";
|
this.componentName = componentName || "";
|
||||||
|
this.colour = options.colour || "white";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -26,7 +28,7 @@ Log a message
|
|||||||
*/
|
*/
|
||||||
Logger.prototype.log = function(/* args */) {
|
Logger.prototype.log = function(/* args */) {
|
||||||
if(console !== undefined && console.log !== undefined) {
|
if(console !== undefined && console.log !== undefined) {
|
||||||
return Function.apply.call(console.log, console, [this.componentName + ":"].concat(Array.prototype.slice.call(arguments,0)));
|
return Function.apply.call(console.log, console, [$tw.utils.terminalColour(this.colour),this.componentName + ":"].concat(Array.prototype.slice.call(arguments,0)).concat($tw.utils.terminalColour()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,43 @@ Various static utility functions.
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
/*
|
||||||
|
Display a message, in colour if we're on a terminal
|
||||||
|
*/
|
||||||
|
exports.log = function(text,colour) {
|
||||||
|
console.log($tw.node ? exports.terminalColour(colour) + text + exports.terminalColour() : text);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.terminalColour = function(colour) {
|
||||||
|
if($tw.node) {
|
||||||
|
if(colour) {
|
||||||
|
var code = exports.terminalColourLookup[colour];
|
||||||
|
if(code) {
|
||||||
|
return "\x1b[" + code + "m";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return "\x1b[0m"; // Cancel colour
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.terminalColourLookup = {
|
||||||
|
"black": "0;30",
|
||||||
|
"red": "0;31",
|
||||||
|
"green": "0;32",
|
||||||
|
"brown/orange": "0;33",
|
||||||
|
"blue": "0;34",
|
||||||
|
"purple": "0;35",
|
||||||
|
"cyan": "0;36",
|
||||||
|
"light gray": "0;37"
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Display a warning, in colour if we're on a terminal
|
Display a warning, in colour if we're on a terminal
|
||||||
*/
|
*/
|
||||||
exports.warning = function(text) {
|
exports.warning = function(text) {
|
||||||
console.log($tw.node ? "\x1b[1;33m" + text + "\x1b[0m" : text);
|
exports.log(text,"brown/orange");
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ var fs = $tw.node ? require("fs") : null,
|
|||||||
function FileSystemAdaptor(options) {
|
function FileSystemAdaptor(options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.wiki = options.wiki;
|
this.wiki = options.wiki;
|
||||||
this.logger = new $tw.utils.Logger("FileSystem");
|
this.logger = new $tw.utils.Logger("filesystem",{colour: "blue"});
|
||||||
// Create the <wiki>/tiddlers folder if it doesn't exist
|
// Create the <wiki>/tiddlers folder if it doesn't exist
|
||||||
$tw.utils.createDirectory($tw.boot.wikiTiddlersPath);
|
$tw.utils.createDirectory($tw.boot.wikiTiddlersPath);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user