loglevel-mixin
Advanced tools
Comparing version 1.6.13 to 1.6.14
@@ -41,7 +41,7 @@ 'use strict'; | ||
* @param {object} logLevels Hash with all the available loglevels. Stored by there name | ||
* @param {function} theFunction The function to be added under the loglevel name. | ||
* @param {function} [theFunction] The function to be added under the loglevel name. | ||
* This function will only be called if the current loglevel is greater equal | ||
* the log level of the called logging function. | ||
* By default a method log(level,message) will be used | ||
* @return {void} | ||
* @return {undefined} | ||
*/ | ||
@@ -98,4 +98,7 @@ function defineLoggerMethods(object, logLevels = defaultLogLevels, theFunction = undefined) { | ||
return class extends superclass { | ||
constructor() { | ||
super(); | ||
/** | ||
* set the log level to the default | ||
*/ | ||
constructor(...args) { | ||
super(...args); | ||
this._logLevel = defaultLogLevel; | ||
@@ -131,8 +134,8 @@ } | ||
* Declares two properties: | ||
* logLevel {String} `info`,`error`,... | ||
* logLevelPriority {Number} | ||
* logLevel {string} `info`,`error`,... | ||
* logLevelPriority {number} | ||
* | ||
* @param {object} object target where the properties will be written into | ||
* @param {object} logLevels Hash with all the available loglevels. Stored by there name; defaults to defaultLogLevels | ||
* @param {string} defaultLogLevel the default value for the properties; defaults to `info` | ||
* @param {object} [logLevels=defaultLogLevels] Hash with all the available loglevels. Stored by there name; defaults to defaultLogLevels | ||
* @param {string} [defaultLogLevel=info] the default value for the properties; defaults to `info` | ||
*/ | ||
@@ -166,3 +169,3 @@ function defineLogLevelProperties(object, logLevels = defaultLogLevels, defaultLogLevel = defaultLogLevels.info) { | ||
* @param {string|object} arg original log message - level and timestamp may be overwritten | ||
* @param {object} args additional values to be merged into the final log event - values have precedence | ||
* @param {object} [args] additional values to be merged into the final log event - values have precedence | ||
* @return {object} suitable for log event processing | ||
@@ -202,2 +205,3 @@ */ | ||
exports.defaultLogLevels = defaultLogLevels; | ||
exports.declareLevels = declareLevels; | ||
exports.defineLoggerMethods = defineLoggerMethods; | ||
@@ -204,0 +208,0 @@ exports.LogLevelMixin = LogLevelMixin; |
{ | ||
"name": "loglevel-mixin", | ||
"version": "1.6.13", | ||
"version": "1.6.14", | ||
"description": "mixin to declare logging methods named after a set of log levels", | ||
@@ -32,3 +32,3 @@ "main": "dist/LogLevelMixin.js", | ||
"mocha": "^3.2.0", | ||
"rollup": "^0.39.2", | ||
"rollup": "^0.40.0", | ||
"semantic-release": "^6.3.5" | ||
@@ -35,0 +35,0 @@ }, |
@@ -10,2 +10,3 @@ [![npm](https://img.shields.io/npm/v/loglevel-mixin.svg)](https://www.npmjs.com/package/loglevel-mixin) | ||
[![GitHub Issues](https://img.shields.io/github/issues/arlac77/loglevel-mixin.svg?style=flat-square)](https://github.com/arlac77/loglevel-mixin/issues) | ||
[![Stories in Ready](https://badge.waffle.io/arlac77/loglevel-mixin.svg?label=ready&title=Ready)](http://waffle.io/arlac77/loglevel-mixin) | ||
[![Dependency Status](https://david-dm.org/arlac77/loglevel-mixin.svg)](https://david-dm.org/arlac77/loglevel-mixin) | ||
@@ -74,8 +75,8 @@ [![devDependency Status](https://david-dm.org/arlac77/loglevel-mixin/dev-status.svg)](https://david-dm.org/arlac77/loglevel-mixin#info=devDependencies) | ||
* <a name="module_loglevel-mixin..declareLevels"></a> | ||
* <a name="module_loglevel-mixin.declareLevels"></a> | ||
## loglevel-mixin~declareLevels(list) ⇒ <code>object</code> | ||
## loglevel-mixin.declareLevels(list) ⇒ <code>object</code> | ||
Generate the loglevel objects out of a list of log level names. | ||
**Kind**: inner method of <code>[loglevel-mixin](#module_loglevel-mixin)</code> | ||
**Kind**: static method of <code>[loglevel-mixin](#module_loglevel-mixin)</code> | ||
**Returns**: <code>object</code> - levels object A hash with all the loglevels. Stored by there name. | ||
@@ -88,9 +89,9 @@ | ||
* <a name="module_loglevel-mixin..defineLoggerMethods"></a> | ||
* <a name="module_loglevel-mixin.defineLoggerMethods"></a> | ||
## loglevel-mixin~defineLoggerMethods(object, logLevels, theFunction) ⇒ <code>void</code> | ||
## loglevel-mixin.defineLoggerMethods(object, logLevels, theFunction) ⇒ <code>void</code> | ||
Adds logging methods to an existing object. | ||
For each loglevel a method with the name of the log level will be created. | ||
**Kind**: inner method of <code>[loglevel-mixin](#module_loglevel-mixin)</code> | ||
**Kind**: static method of <code>[loglevel-mixin](#module_loglevel-mixin)</code> | ||
@@ -104,5 +105,5 @@ | Param | Type | Description | | ||
* <a name="module_loglevel-mixin..defineLogLevelProperties"></a> | ||
* <a name="module_loglevel-mixin.defineLogLevelProperties"></a> | ||
## loglevel-mixin~defineLogLevelProperties(object, logLevels, defaultLogLevel) | ||
## loglevel-mixin.defineLogLevelProperties(object, logLevels, defaultLogLevel) | ||
Declares two properties: | ||
@@ -112,3 +113,3 @@ logLevel {String} `info`,`error`,... | ||
**Kind**: inner method of <code>[loglevel-mixin](#module_loglevel-mixin)</code> | ||
**Kind**: static method of <code>[loglevel-mixin](#module_loglevel-mixin)</code> | ||
@@ -122,8 +123,8 @@ | Param | Type | Description | | ||
* <a name="module_loglevel-mixin..makeLogEvent"></a> | ||
* <a name="module_loglevel-mixin.makeLogEvent"></a> | ||
## loglevel-mixin~makeLogEvent(level, arg, args) ⇒ <code>object</code> | ||
## loglevel-mixin.makeLogEvent(level, arg, args) ⇒ <code>object</code> | ||
Helper function to aggregate values into a log event | ||
**Kind**: inner method of <code>[loglevel-mixin](#module_loglevel-mixin)</code> | ||
**Kind**: static method of <code>[loglevel-mixin](#module_loglevel-mixin)</code> | ||
**Returns**: <code>object</code> - suitable for log event processing | ||
@@ -130,0 +131,0 @@ |
@@ -12,3 +12,3 @@ /* jslint node: true, esnext: true */ | ||
*/ | ||
const defaultLogLevels = declareLevels(['trace', 'debug', 'info', 'notice', 'warn', 'error', 'crit', 'alert']); | ||
export const defaultLogLevels = declareLevels(['trace', 'debug', 'info', 'notice', 'warn', 'error', 'crit', 'alert']); | ||
@@ -20,3 +20,3 @@ /** | ||
*/ | ||
function declareLevels(list) { | ||
export function declareLevels(list) { | ||
const levels = {}; | ||
@@ -41,9 +41,9 @@ let priority = list.length; | ||
* @param {object} logLevels Hash with all the available loglevels. Stored by there name | ||
* @param {function} theFunction The function to be added under the loglevel name. | ||
* @param {function} [theFunction] The function to be added under the loglevel name. | ||
* This function will only be called if the current loglevel is greater equal | ||
* the log level of the called logging function. | ||
* By default a method log(level,message) will be used | ||
* @return {void} | ||
* @return {undefined} | ||
*/ | ||
function defineLoggerMethods(object, logLevels = defaultLogLevels, theFunction = undefined) { | ||
export function defineLoggerMethods(object, logLevels = defaultLogLevels, theFunction = undefined) { | ||
const properties = {}; | ||
@@ -96,6 +96,9 @@ | ||
*/ | ||
function LogLevelMixin(superclass, logLevels = defaultLogLevels, defaultLogLevel = defaultLogLevels.info) { | ||
export function LogLevelMixin(superclass, logLevels = defaultLogLevels, defaultLogLevel = defaultLogLevels.info) { | ||
return class extends superclass { | ||
constructor() { | ||
super(); | ||
/** | ||
* set the log level to the default | ||
*/ | ||
constructor(...args) { | ||
super(...args); | ||
this._logLevel = defaultLogLevel; | ||
@@ -131,10 +134,10 @@ } | ||
* Declares two properties: | ||
* logLevel {String} `info`,`error`,... | ||
* logLevelPriority {Number} | ||
* logLevel {string} `info`,`error`,... | ||
* logLevelPriority {number} | ||
* | ||
* @param {object} object target where the properties will be written into | ||
* @param {object} logLevels Hash with all the available loglevels. Stored by there name; defaults to defaultLogLevels | ||
* @param {string} defaultLogLevel the default value for the properties; defaults to `info` | ||
* @param {object} [logLevels=defaultLogLevels] Hash with all the available loglevels. Stored by there name; defaults to defaultLogLevels | ||
* @param {string} [defaultLogLevel=info] the default value for the properties; defaults to `info` | ||
*/ | ||
function defineLogLevelProperties(object, logLevels = defaultLogLevels, defaultLogLevel = defaultLogLevels.info) { | ||
export function defineLogLevelProperties(object, logLevels = defaultLogLevels, defaultLogLevel = defaultLogLevels.info) { | ||
const properties = {}; | ||
@@ -166,6 +169,6 @@ | ||
* @param {string|object} arg original log message - level and timestamp may be overwritten | ||
* @param {object} args additional values to be merged into the final log event - values have precedence | ||
* @param {object} [args] additional values to be merged into the final log event - values have precedence | ||
* @return {object} suitable for log event processing | ||
*/ | ||
function makeLogEvent(level, arg, args) { | ||
export function makeLogEvent(level, arg, args) { | ||
const logevent = { | ||
@@ -200,9 +203,1 @@ timestamp: Date.now(), | ||
} | ||
export { | ||
defaultLogLevels, | ||
defineLoggerMethods, | ||
LogLevelMixin, | ||
defineLogLevelProperties, | ||
makeLogEvent | ||
}; |
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
21188
139