@voliware/logger
Advanced tools
Comparing version 1.5.2 to 1.5.3
{ | ||
"name": "@voliware/logger", | ||
"version": "1.5.2", | ||
"version": "1.5.3", | ||
"description": "A tiny Javascript logger with levels and several options. Supports Node and all modern Browsers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -30,10 +30,10 @@ /** | ||
* Constructor | ||
* @param {string} name - name of the logger | ||
* @param {object} [options={}] | ||
* @param {number} [options.level=Logger.level.info] - starting log level | ||
* @param {object|boolean} [options.timestamp] - timestamp options, or boolean for default time format | ||
* @param {boolean} [options.objectsToString=false] - whether to print objects using .toString() | ||
* @param {boolean} [options.timestamp.state=false] - whether to print timestamps | ||
* @param {number} [options.timestamp.format=Logger.timestamp.locale] - timestamp format | ||
* @param {string} [options.context=null] - optional context appended after logger name | ||
* @param {String} name - name of the logger | ||
* @param {Object} [options={}] | ||
* @param {Number} [options.level=Logger.level.info] - starting log level | ||
* @param {Object|Boolean} [options.timestamp] - timestamp options, or boolean for default time format | ||
* @param {Boolean} [options.objectsToString=false] - whether to print objects using .toString() | ||
* @param {Boolean} [options.timestamp.state=false] - whether to print timestamps | ||
* @param {Number} [options.timestamp.format=Logger.timestamp.locale] - timestamp format | ||
* @param {String} [options.context=null] - optional context appended after logger name | ||
* @return {Logger} | ||
@@ -61,3 +61,3 @@ */ | ||
* Get the logger's enabled state. | ||
* @returns {boolean} true if enabled | ||
* @returns {Boolean} true if enabled | ||
*/ | ||
@@ -70,3 +70,3 @@ getEnabled(){ | ||
* Set the logger's enabled state. | ||
* @param {boolean} enabled | ||
* @param {Boolean} enabled | ||
* @returns {Logger} | ||
@@ -98,3 +98,3 @@ */ | ||
* as the first item in the message after timestamp. | ||
* @param {string} name | ||
* @param {String} name | ||
*/ | ||
@@ -107,5 +107,13 @@ setName(name){ | ||
/** | ||
* Get the currnet log level | ||
* @returns {Number} | ||
*/ | ||
getLevel(){ | ||
return this.options.level; | ||
} | ||
/** | ||
* Set the log level. | ||
* This will immediately change the logger's log level. | ||
* @param {number} level | ||
* @param {Number} level | ||
* @return {Logger} | ||
@@ -129,5 +137,5 @@ */ | ||
* Set any timestamp options | ||
* @param {object|boolean} options - options or true to use default timestamp | ||
* @param {boolean} [options.state] - whether to print timestamps | ||
* @param {number} [options.format] - timestamp format | ||
* @param {Object|Boolean} options - options or true to use default timestamp | ||
* @param {Boolean} [options.state] - whether to print timestamps | ||
* @param {Number} [options.format] - timestamp format | ||
* @return {Logger} | ||
@@ -149,3 +157,3 @@ */ | ||
* Set the timestamp printing state | ||
* @param {boolean} state | ||
* @param {Boolean} state | ||
* @return {Logger} | ||
@@ -160,3 +168,3 @@ */ | ||
* Set the timestamp format | ||
* @param {number} format | ||
* @param {Number} format | ||
* @return {Logger} | ||
@@ -240,4 +248,4 @@ */ | ||
* Create a log message. | ||
* @param {string} message - message to log | ||
* @param {number} level - log level | ||
* @param {String} message - message to log | ||
* @param {Number} level - log level | ||
* @return {Logger} | ||
@@ -268,3 +276,3 @@ */ | ||
* log level is greater than the specified one. | ||
* @param {string} message - message to log | ||
* @param {String} message - message to log | ||
* @param {number|string} [level=this.options.level] - log level; current level by default | ||
@@ -296,3 +304,3 @@ * @return {Logger} | ||
* This is the actual log output function. | ||
* @param {string} message - message to log | ||
* @param {String} message - message to log | ||
* @return {Logger} | ||
@@ -315,3 +323,3 @@ */ | ||
* when debugging program flow. | ||
* @param {string} message | ||
* @param {String} message | ||
* @return {Logger} | ||
@@ -325,3 +333,3 @@ */ | ||
* Log a debug message | ||
* @param {string} message | ||
* @param {String} message | ||
* @return {Logger} | ||
@@ -335,3 +343,3 @@ */ | ||
* Log an info message | ||
* @param {string} message | ||
* @param {String} message | ||
* @return {Logger} | ||
@@ -345,3 +353,3 @@ */ | ||
* Log a warning message | ||
* @param {string} message | ||
* @param {String} message | ||
* @return {Logger} | ||
@@ -355,3 +363,3 @@ */ | ||
* Log an error message | ||
* @param {string} message | ||
* @param {String} message | ||
* @return {Logger} | ||
@@ -380,2 +388,3 @@ */ | ||
* Map of strings to Logger levels | ||
* @type {Map<String, Number>} | ||
*/ | ||
@@ -391,4 +400,4 @@ Logger.level.stringmap = new Map() | ||
* Check if the log level is valid | ||
* @param {number} level | ||
* @return {boolean} | ||
* @param {Number} level | ||
* @return {Boolean} | ||
*/ | ||
@@ -399,2 +408,6 @@ Logger.level.isValidLevel = function(level){ | ||
/** | ||
* Timestamp enum | ||
* @type {Object} | ||
*/ | ||
Logger.timestamp = { | ||
@@ -409,2 +422,3 @@ utc: 0, | ||
* Map of strings to Logger timestamps | ||
* @type {Map<String, Number>} | ||
*/ | ||
@@ -419,4 +433,4 @@ Logger.timestamp.stringmap = new Map() | ||
* Check if the timestamp is valid | ||
* @param {number} timestamp | ||
* @return {boolean} | ||
* @param {Number} timestamp | ||
* @return {Boolean} | ||
*/ | ||
@@ -423,0 +437,0 @@ Logger.timestamp.isValidTimestamp = function(timestamp){ |
@@ -10,9 +10,9 @@ const Logger = require('./logger'); | ||
* let logger = new Logger("Module", { | ||
* level: Logger.level.debug, | ||
* timestamp: true, | ||
* output: { | ||
* console: true, | ||
* file: "./logs/module.txt" | ||
* } | ||
* }); | ||
* level: Logger.level.debug, | ||
* timestamp: true, | ||
* output: { | ||
* console: true, | ||
* file: "./logs/module.txt" | ||
* } | ||
* }); | ||
*/ | ||
@@ -23,12 +23,12 @@ class NodeLogger extends Logger { | ||
* Constructor | ||
* @param {string} name - name of the logger | ||
* @param {object} [options={}] | ||
* @param {number} [options.level=Logger.level.info] - starting log level | ||
* @param {object|boolean} [options.timestamp] - timestamp options, or boolean for default time format | ||
* @param {boolean} [options.timestamp.state=false] - whether to print timestamps | ||
* @param {number} [options.timestamp.format=Logger.timestamp.locale] - timestamp format | ||
* @param {string} [options.context=null] - optional context appended after logger name | ||
* @param {object} [options.output] | ||
* @param {boolean} [options.output.console=true] - whether to output to the console | ||
* @param {string} [options.output.file=""] - a file to save the log to, or blank for none | ||
* @param {String} name - name of the logger | ||
* @param {Object} [options={}] | ||
* @param {Number} [options.level=Logger.level.info] - starting log level | ||
* @param {Object|boolean} [options.timestamp] - timestamp options, or boolean for default time format | ||
* @param {Boolean} [options.timestamp.state=false] - whether to print timestamps | ||
* @param {Number} [options.timestamp.format=Logger.timestamp.locale] - timestamp format | ||
* @param {String} [options.context=null] - optional context appended after logger name | ||
* @param {Object} [options.output] | ||
* @param {Boolean} [options.output.console=true] - whether to output to the console | ||
* @param {String} [options.output.file=""] - a file to save the log to, or blank for none | ||
* @return {Logger} | ||
@@ -53,3 +53,3 @@ */ | ||
* Check if this is a node environment | ||
* @return {boolean} true if it is | ||
* @return {Boolean} true if it is | ||
*/ | ||
@@ -62,4 +62,4 @@ isNodeEnv(){ | ||
* Check if a file path is valid | ||
* @param {string} filepath - file path | ||
* @return {boolean} true if it is | ||
* @param {String} filepath - file path | ||
* @return {Boolean} true if it is | ||
*/ | ||
@@ -72,3 +72,3 @@ isValidFilepath(filepath){ | ||
* Set the state of logging to the console. | ||
* @param {boolean} state - true to enable | ||
* @param {Boolean} state - true to enable | ||
* @return {NodeLogger} | ||
@@ -83,3 +83,3 @@ */ | ||
* Set the out file path | ||
* @param {string} filepath - file path | ||
* @param {String} filepath - file path | ||
* @return {NodeLogger} | ||
@@ -101,3 +101,3 @@ */ | ||
* Automatically adds an end of line character. | ||
* @param {string} text - text to append | ||
* @param {String} text - text to append | ||
* @return {Promise<NodeLogger>} | ||
@@ -154,3 +154,3 @@ */ | ||
* Can do both. | ||
* @param {string} message - message to log | ||
* @param {String} message - message to log | ||
* @async | ||
@@ -157,0 +157,0 @@ * @return {Promise<NodeLogger>} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28948
704