New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

debug-logtron

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debug-logtron - npm Package Compare versions

Comparing version 5.0.0 to 5.1.0

lib/base-logtron.js

13

backends/debug-log-backend.js

@@ -7,5 +7,4 @@ 'use strict';

var TypedError = require('error/typed');
var TermColor = require('term-color');
var TermColor = require('../lib/term-color.js');
var validNamespaceRegex = /^[a-zA-Z0-9]+$/;

@@ -35,3 +34,3 @@ var InvalidNamespaceError = TypedError({

function DebugLogBackend(namespace, opts) {
/*eslint max-statements: [2, 25]*/
/* eslint max-statements: [2, 25] */
if (!(this instanceof DebugLogBackend)) {

@@ -95,2 +94,8 @@ return new DebugLogBackend(namespace, opts);

DebugLogBackend.prototype.unwhitelist = function unwhitelist(level, msg) {
var self = this;
self.whitelists[level][msg] = false;
};
DebugLogBackend.prototype.createStream = function createStream() {

@@ -124,2 +129,3 @@ var self = this;

/* istanbul ignore else */
if (cb) {

@@ -151,2 +157,3 @@ cb();

/* istanbul ignore else */
if (cb) {

@@ -153,0 +160,0 @@ cb();

'use strict';
var LogMessage = require('./log-message.js');
var util = require('util');
var BaseLogtron = require('./lib/base-logtron.js');
var DebugLogBackend = require('./backends/debug-log-backend.js');
var LEVELS = require('./levels.js').LEVELS_BY_NAME;

@@ -18,47 +19,19 @@ module.exports = DebugLogtron;

this._backend = DebugLogBackend(namespace, opts);
this._stream = this._backend.createStream();
this._backend = DebugLogBackend(this.name, opts);
BaseLogtron.call(this, {
streams: [this._backend.createStream()]
});
}
util.inherits(DebugLogtron, BaseLogtron);
DebugLogtron.prototype._log = function _log(level, msg, meta, cb) {
var logMessage = new LogMessage(level, msg, meta);
LogMessage.isValid(logMessage);
this._stream.write(logMessage, cb);
DebugLogtron.prototype.whitelist = function whitelist(level, msg) {
this._backend.whitelist(level, msg);
};
DebugLogtron.prototype.trace = function trace(msg, meta, cb) {
this._log(LEVELS.trace, msg, meta, cb);
DebugLogtron.prototype.unwhitelist = function unwhitelist(level, msg) {
this._backend.unwhitelist(level, msg);
};
DebugLogtron.prototype.debug = function debug(msg, meta, cb) {
this._log(LEVELS.debug, msg, meta, cb);
};
DebugLogtron.prototype.info = function info(msg, meta, cb) {
this._log(LEVELS.info, msg, meta, cb);
};
DebugLogtron.prototype.access = function access(msg, meta, cb) {
this._log(LEVELS.access, msg, meta, cb);
};
DebugLogtron.prototype.warn = function warn(msg, meta, cb) {
this._log(LEVELS.warn, msg, meta, cb);
};
DebugLogtron.prototype.error = function error(msg, meta, cb) {
this._log(LEVELS.error, msg, meta, cb);
};
DebugLogtron.prototype.fatal = function fatal(msg, meta, cb) {
this._log(LEVELS.fatal, msg, meta, cb);
};
DebugLogtron.prototype.whitelist = function whitelist(level, msg) {
this._backend.whitelist(level, msg);
};
DebugLogtron.prototype.items = function items() {
return this._backend.records;
};
{
"name": "debug-logtron",
"version": "5.0.0",
"version": "5.1.0",
"description": "A debug logger with a logtron interface.",

@@ -20,6 +20,7 @@ "keywords": [],

"dependencies": {
"ansi-styles": "^2.0.1",
"collect-parallel": "1.0.1",
"error": "^7.0.1",
"process": "^0.11.1",
"supports-color": "^1.3.1",
"term-color": "1.0.1",
"xtend": "^4.0.0"

@@ -26,0 +27,0 @@ },

@@ -43,11 +43,11 @@ # debug-logtron

var test = require('tape');
test('some module', function t(assert) {
var logger = NullLogtron('mything');
var thing = new Thing({ logger: logger })
logger.whitelist('error', 'some msg');
thing.doStuff();
var items = logger.items();

@@ -61,2 +61,6 @@ assert.equal(items.filter(function (x) {

Whilst it is recommended that you minimize state between tests by creating
a new instance of debug-logtron, it is possible to remove a whitelisted item
by calling `.unwhitelist` with the same arguments.
## Interface

@@ -79,3 +83,3 @@

If you want to add a default logger to your `dependencies`
If you want to add a default logger to your `dependencies`
then I strongly recommend you use [`null-logtron`][null-logtron]

@@ -82,0 +86,0 @@

@@ -6,9 +6,8 @@ 'use strict';

var os = require('os');
var TermColor = require('term-color');
var TermColor = require('../lib/term-color.js');
TermColor.enabled = false;
var DebugLogtron = require('../index.js');
var LogMessage = require('../log-message.js');
var LogMessage = require('../lib/log-message.js');

@@ -407,2 +406,25 @@ test('DebugLogtron is a function', function t(assert) {

test('can unwhitelist errors', function t(assert) {
var logger = allocLogger();
assert.throws(function throwIt() {
logger.error('oh hi');
}, /oh hi/);
logger.whitelist('error', 'oh hi');
logger.error('oh hi');
assert.equal(logger.items().length, 1);
assert.equal(logger.items()[0].msg, 'oh hi');
logger.unwhitelist('error', 'oh hi');
assert.throws(function throwIt() {
logger.error('oh hi');
}, /oh hi/);
assert.end();
});
function allocLogger(opts) {

@@ -409,0 +431,0 @@ opts = opts || {};

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