diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2020-09-20 19:47:28 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2020-09-20 19:47:28 +0200 |
| commit | 58906d77975b35fe93569f8083b90140124f9c41 (patch) | |
| tree | 36ec38adf065424d547ef73d014913c503ab40fe /lib/formatters | |
| parent | 4b10e604bf4057d7ae8286151d7528d7d7ae1cb9 (diff) | |
Recover from npm package
Diffstat (limited to 'lib/formatters')
| -rw-r--r-- | lib/formatters/ansi.js | 29 | ||||
| -rw-r--r-- | lib/formatters/simple.js | 11 | ||||
| -rw-r--r-- | lib/formatters/token.js | 73 |
3 files changed, 0 insertions, 113 deletions
diff --git a/lib/formatters/ansi.js b/lib/formatters/ansi.js deleted file mode 100644 index 806869a..0000000 --- a/lib/formatters/ansi.js +++ /dev/null @@ -1,29 +0,0 @@ -if (typeof require === 'function') { - require('colors'); -} - -Module(Cobalt.Formatter, 'Ansi')({ - format : function (logObject, opts){ - var indent, - message; - - indent = Array(logObject._indentLevel + 1).join(' '); - - message = indent + logObject.message; - - switch(logObject._level) { - case 0: - case 1: - case 2: - case 3: - return message.red; - case 4: - return message.yellow; - case 5: - case 6: - return message.blue; - default: - return message; - } - } -}); diff --git a/lib/formatters/simple.js b/lib/formatters/simple.js deleted file mode 100644 index 9eb6bbe..0000000 --- a/lib/formatters/simple.js +++ /dev/null @@ -1,11 +0,0 @@ -Module(Cobalt.Formatter, 'Simple')({ - format : function (logObject, opts){ - var indent, date; - - indent = Array(logObject._indentLevel + 1).join(' '); - - date = new Date(logObject._timestamp); - - return indent + '[' + date.toISOString() + '][' + logObject._levelString + '] ' + logObject._from + ' : ' + logObject.message; - } -}); diff --git a/lib/formatters/token.js b/lib/formatters/token.js deleted file mode 100644 index f3afba2..0000000 --- a/lib/formatters/token.js +++ /dev/null @@ -1,73 +0,0 @@ -Module(Cobalt.Formatter, 'Token')({ - formatString : "{{message}}", - replaceRule : /{{(.*?)}}/g, - separatorLength : 60, - isoDate : true, - separatorType : "-", - format : function (logObject, opts){ - var indent, indentSize, - separatorLength, separatorType, - output, property; - indentSize = logObject._indentLevel || 0; - - // Extend opts - if (opts) { - for (property in opts) { - if (opts.hasOwnProperty(property)) { - this[property] = opts[property]; - } - } - } - - indent = Array(indentSize + 1).join(' '); - - if (logObject._separator) { - separatorLength = logObject._separatorLength || this.separatorLength; - separatorType = logObject._separatorType || this.separatorType; - output = indent + Array(separatorLength - indentSize + 1).join(separatorType); - } else { - output = indent + this.parseFormatString(logObject, this.formatString); - } - - if (this.ansiColor) { - output = this.colorize(logObject._level, output); - } - - return output; - }, - - parseFormatString : function (logObject, formatString) { - var resultString = ''; - if (typeof formatString === 'undefined') { - formatString = this.formatString; - } - - resultString = formatString.replace(this.replaceRule, function(match, paren){ - var date; - if (paren === "_timestamp" && this.isoDate) { - date = new Date(logObject[paren]); - return date.toISOString(); - } - return logObject[paren] || "-"; - }.bind(this)); - - return resultString; - }, - - colorize : function (level, message) { - switch(level) { - case 0: - case 1: - case 2: - case 3: - return message.red; - case 4: - return message.yellow; - case 5: - case 6: - return message.blue; - default: - return message; - } - } -}); |