forked from NarrativeScience-old/log.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logging module with log levels.
Removed module-level LOGGERs, attached logger instances to Harvester, Server instances for better encapsulation, stubbing. Modified Stream, History button CSS, just 'cause.
- Loading branch information
Showing
10 changed files
with
97 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* Generic logging module. | ||
* | ||
* Log Levels: | ||
* - 3 (Debug) | ||
* - 2 (Info) | ||
* - 1 (Warn) | ||
* - 0 (Error) | ||
*/ | ||
|
||
var Logger = function(log_level) { | ||
this._log_level = log_level ? log_level : 2 | ||
} | ||
|
||
Logger.prototype = { | ||
_timestamp: function(msg) { | ||
return (new Date()).toLocaleString().slice(0,24); | ||
}, | ||
|
||
debug: function(msg) { | ||
if (this._log_level < 3) { return; } | ||
console.info("[" + this._timestamp() + "] DEBUG: " + msg); | ||
}, | ||
|
||
info: function(msg) { | ||
if (this._log_level < 2) { return; } | ||
console.info("[" + this._timestamp() + "] INFO: " + msg); | ||
}, | ||
|
||
warn: function(msg) { | ||
if (this._log_level < 1) { return; } | ||
console.warn("[" + this._timestamp() + "] WARN: " + msg); | ||
}, | ||
|
||
error: function(msg) { | ||
if (this._log_level < 0) { return; } | ||
console.error("[" + this._timestamp() + "] ERROR: " + msg); | ||
} | ||
} | ||
|
||
exports.Logger = Logger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters