Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

loglevel-mixin

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loglevel-mixin - npm Package Compare versions

Comparing version 1.6.22 to 2.0.1

dist/loglevel-mixin.js

77

dist/LogLevelMixin.js

@@ -14,3 +14,12 @@ 'use strict';

*/
const defaultLogLevels = declareLevels(['trace', 'debug', 'info', 'notice', 'warn', 'error', 'crit', 'alert']);
const defaultLogLevels = declareLevels([
'trace',
'debug',
'info',
'notice',
'warn',
'error',
'crit',
'alert'
]);

@@ -48,3 +57,7 @@ /**

*/
function defineLoggerMethods(object, logLevels = defaultLogLevels, theFunction = undefined) {
function defineLoggerMethods(
object,
logLevels = defaultLogLevels,
theFunction = undefined
) {
const properties = {};

@@ -56,18 +69,24 @@

properties[levelName] = {
value: theFunction !== undefined ?
function (providerFunction) {
if (this.logLevelPriority >= myLevel)
if (typeof providerFunction === 'function') {
theFunction.call(this, levelName, providerFunction(levelName));
} else {
theFunction.call(this, levelName, providerFunction);
value:
theFunction !== undefined
? function(providerFunction) {
if (this.logLevelPriority >= myLevel)
if (typeof providerFunction === 'function') {
theFunction.call(
this,
levelName,
providerFunction(levelName)
);
} else {
theFunction.call(this, levelName, providerFunction);
}
}
} : function (providerFunction) {
if (this.logLevelPriority >= myLevel)
if (typeof providerFunction === 'function') {
this.log(levelName, providerFunction(levelName));
} else {
this.log(levelName, providerFunction);
}
},
: function(providerFunction) {
if (this.logLevelPriority >= myLevel)
if (typeof providerFunction === 'function') {
this.log(levelName, providerFunction(levelName));
} else {
this.log(levelName, providerFunction);
}
},
enumerable: true

@@ -80,3 +99,2 @@ };

/**

@@ -98,4 +116,9 @@ * @class

* ```
* @mixin
*/
function LogLevelMixin(superclass, logLevels = defaultLogLevels, defaultLogLevel = defaultLogLevels.info) {
function LogLevelMixin(
superclass,
logLevels = defaultLogLevels,
defaultLogLevel = defaultLogLevels.info
) {
return class extends superclass {

@@ -144,3 +167,7 @@ /**

*/
function defineLogLevelProperties(object, logLevels = defaultLogLevels, defaultLogLevel = defaultLogLevels.info) {
function defineLogLevelProperties(
object,
logLevels = defaultLogLevels,
defaultLogLevel = defaultLogLevels.info
) {
const properties = {};

@@ -152,7 +179,7 @@

get() {
return logLevel.name;
},
set(level) {
logLevel = logLevels[level] || defaultLogLevel;
}
return logLevel.name;
},
set(level) {
logLevel = logLevels[level] || defaultLogLevel;
}
};

@@ -159,0 +186,0 @@

{
"name": "loglevel-mixin",
"version": "1.6.22",
"version": "2.0.1",
"description": "mixin to declare logging methods named after a set of log levels",
"main": "dist/LogLevelMixin.js",
"module": "src/LogLevelMixin.js",
"main": "dist/loglevel-mixin.js",
"module": "src/loglevel-mixin.js",
"scripts": {
"cover": "nyc npm test",
"docs": "jsdoc2md -l off -t doc/README.hbs -f src/*.js >README.md",
"test": "mocha tests/*_test.js",
"test": "mocha tests/*-test.js",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"prepublish": "rollup --output=dist/LogLevelMixin.js -c -- src/LogLevelMixin.js",
"pretest": "npm run prepublish",
"pretest": "rollup -c",
"posttest": "markdown-doctest",
"precover": "npm run prepublish"
"precover": "rollup -c",
"prepare": "rollup -c"
},
"repository": {
"type": "git",
"url": "https://github.com/arlac77/loglevel-mixin.git"
"url": "git+https://github.com/arlac77/loglevel-mixin.git"
},
"engines": {
"node": ">=7.8.0"
"node": ">=8.6.0"
},
"devDependencies": {
"chai": "^3.5.0",
"chai": "^4.1.2",
"cracks": "3.1.2",
"cz-conventional-changelog": "^2.0.0",
"jsdoc-to-markdown": "^3.0.0",
"markdown-doctest": "^0.9.1",
"mocha": "^3.2.0",
"nyc": "^10.2.0",
"rollup": "^0.41.6",
"semantic-release": "^6.3.6"
"mocha": "^4.0.0",
"nyc": "^11.2.1",
"rollup": "^0.50.0",
"semantic-release": "^8.0.4"
},

@@ -47,7 +46,2 @@ "release": {

"homepage": "https://github.com/arlac77/loglevel-mixin#readme",
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"dependencies": {},

@@ -73,3 +67,6 @@ "contributors": [

}
},
"xo": {
"space": true
}
}
}
[![npm](https://img.shields.io/npm/v/loglevel-mixin.svg)](https://www.npmjs.com/package/loglevel-mixin)
[![Greenkeeper](https://badges.greenkeeper.io/arlac77/loglevel-mixin)](https://greenkeeper.io/)
[![Greenkeeper](https://badges.greenkeeper.io/arlac77/loglevel-mixin.svg)](https://greenkeeper.io/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/arlac77/loglevel-mixin)

@@ -21,4 +21,6 @@ [![Build Status](https://secure.travis-ci.org/arlac77/loglevel-mixin.png)](http://travis-ci.org/arlac77/loglevel-mixin)

Injects methods named after a set of logLevels which are only forwarding messages if the current logLevel is higher or equal to the logLevel the name of the called method reflects.
Injects methods named after a set of logLevels which are only forwarding messages.
If the current logLevel is higher or equal to the logLevel the name of the called method reflects.
usage

@@ -47,11 +49,7 @@ =====

class BaseClass {
const LoggingEnabledClass = llm.LogLevelMixin(class BaseClass
{
log(level, message) { console.log(`${level} ${message}`); }
}
});
llm.defineLoggerMethods(BaseClass.prototype);
class LoggingEnabledClass extends llm.LogLevelMixin(BaseClass) {
}
const someObject = new LoggingEnabledClass();

@@ -82,3 +80,3 @@

**Kind**: static method of <code>[loglevel-mixin](#module_loglevel-mixin)</code>
**Kind**: static method of [<code>loglevel-mixin</code>](#module_loglevel-mixin)
**Returns**: <code>object</code> - levels object A hash with all the loglevels. Stored by there name.

@@ -97,3 +95,3 @@

**Kind**: static method of <code>[loglevel-mixin](#module_loglevel-mixin)</code>
**Kind**: static method of [<code>loglevel-mixin</code>](#module_loglevel-mixin)

@@ -114,3 +112,3 @@ | Param | Type | Description |

**Kind**: static method of <code>[loglevel-mixin](#module_loglevel-mixin)</code>
**Kind**: static method of [<code>loglevel-mixin</code>](#module_loglevel-mixin)

@@ -129,3 +127,3 @@ | Param | Type | Default | Description |

**Kind**: static method of <code>[loglevel-mixin](#module_loglevel-mixin)</code>
**Kind**: static method of [<code>loglevel-mixin</code>](#module_loglevel-mixin)
**Returns**: <code>object</code> - suitable for log event processing

@@ -136,3 +134,3 @@

| level | <code>string</code> | log level |
| arg | <code>string</code> &#124; <code>object</code> | original log message - level and timestamp may be overwritten |
| arg | <code>string</code> \| <code>object</code> | original log message - level and timestamp may be overwritten |
| [args] | <code>object</code> | additional values to be merged into the final log event - values have precedence |

@@ -139,0 +137,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc