diff options
author | Bryan Berry <bryan@olenepal.org> | 2009-11-02 20:45:18 (GMT) |
---|---|---|
committer | Bryan Berry <bryan@olenepal.org> | 2009-11-02 20:45:18 (GMT) |
commit | 25099db20a3e533c0ac6aabdf96c97431993dec8 (patch) | |
tree | 78e5ffe3d2842aa0f055348f5ec4bfad9485c6c6 /utils/lib/logger.js | |
parent | 441f538b4ac4ef05105f59357a32a122602d4aae (diff) |
moved useful stuff in the utils/ directory to bin/ and deleted the rest of the stuff in utils/
Diffstat (limited to 'utils/lib/logger.js')
-rwxr-xr-x | utils/lib/logger.js | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/utils/lib/logger.js b/utils/lib/logger.js deleted file mode 100755 index 8db60e7..0000000 --- a/utils/lib/logger.js +++ /dev/null @@ -1,53 +0,0 @@ -// Logging -// -// FATAL: an unhandleable error that results in a program crash -// ERROR: a handleable error condition -// WARN: a warning -// INFO: generic (useful) information about system operation -// DEBUG: low-level information for developers -// (Stolen from Ruby) -// - -var Logger = exports.Logger = function(output) { - if (typeof output === "string") - this.output = system.fs.open(output, "a"); - else - this.output = output; - - this.level = Logger.INFO; -}; - -Logger.FATAL = 0; -Logger.ERROR = 1; -Logger.WARN = 2; -Logger.INFO = 3; -Logger.DEBUG = 4; - -Logger.SEV_LABEL = ["FATAL", "ERROR", "WARN" , "INFO" , "DEBUG"]; - -Logger.prototype.fatal = function() { - return this.add(Logger.FATAL, this.format(Logger.FATAL, arguments)); -}; -Logger.prototype.error = function() { - return this.add(Logger.ERROR, this.format(Logger.ERROR, arguments)); -}; -Logger.prototype.warn = function() { - return this.add(Logger.WARN, this.format(Logger.WARN, arguments)); -}; -Logger.prototype.info = function() { - return this.add(Logger.INFO, this.format(Logger.INFO, arguments)); -}; -Logger.prototype.debug = function() { - return this.add(Logger.DEBUG, this.format(Logger.DEBUG, arguments)); -}; - -Logger.prototype.add = function(severity, message, progname) { - if (severity > this.level) - return false; - this.output.write(message || progname); -}; - -Logger.prototype.format = function(severity, args) { - return new Date() + " ["+Logger.SEV_LABEL[severity].toLowerCase()+"] " +Array.prototype.join.apply(args, [" "]).replace(/\n/g, ""); -}; - |