Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
This utility is similar to the debug module but without being a singleton, that is, it doesn't enable the debug mode of other third-party modules, which is undesirable. By default, the DEBUG
environment variable is checked and it can contain any value, e.g. DEBUG=true
.
The default formatter prints the messages to the stdout but you're free to log them anywhere by configuring a custom formatter. It also allows subnamespaces similar to the bole module.
// app.js
var debuggy = require('debuggy');
var logger = debuggy.createLogger();
var debug = logger('boot')('http').debug;
debug('Booting up HTTPS server');
$ node app.js
$ DEBUG=true node app.js
2015-01-12T14:17:00.302+01:00 +0ms boot:http Booting up HTTPS server
var util = require('util');
var debuggy = require('./lib');
var logger = debuggy.createLogger({
env: 'TEST',
// This is the default formatter function, adapt it to your needs
format: function (data) {
console.log(this.isoDate(data.date) + ', ' +
this.delay(data.delay) +
(data.namespace ? ', ' + data.namespace : '') + ', ' +
util.format.apply(null, data.arguments));
}
});
var debug = logger('boot')('http').debug;
// If process.env.TEST is truthy is will print the message
debug('Booting up HTTPS server');
$ node app.js
$ DEBUG=true node app.js
$ TEST=true node app.js
2015-01-12T14:17:50.207+01:00, +0ms, boot:http, Booting up HTTPS server
module.createLogger([options]) : Function
Returns a new logger instance. This instance is a function that creates a namespace when called (the namespace is optional). This new namespace can also create new subnamespaces, and so on. Each "namespace-maker" function has a debug
function to log the messages.
var logger = require('debuggy').createLogger();
var debug;
debug = logger.debug;
// debug('foo') <timestamp> <delay> 'foo'
debug = logger('a').debug;
// debug('foo') -> <timestamp> <delay> a 'foo'
debug = logger('a')('b').debug;
// debug('foo') -> <timestamp> <delay> a:b 'foo'
Options:
env - String
Name of the environment variable that's checked to print the messages or not. Default is DEBUG
.
format - Function
Function that formats the messages. By default, it prints to the stdout. It receives one argument, data
, an object with the raw data. It contains the following properties:
logger.debug()
.Date
instance of the current timestamp.this
points to an object with some formatting functions:
logger.debug(...arguments) : undefined
Logs a message. The parameters are untouched and are available in the custom formatter function in the data.arguments
property.
FAQs
Debugging utility tool for development
The npm package debuggy receives a total of 7 weekly downloads. As such, debuggy popularity was classified as not popular.
We found that debuggy demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.