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.
debug-logtron
Advanced tools
A debug logger with a logtron interface.
This logger is designed for tests; it prints info & above
and prints debugs if you set NODE_DEBUG=mylibrary
var DebugLogtron = require("debug-logtron");
var logger = DebugLogtron('mylibrary');
logger.debug('some fixed string', { some: 'meta object' });
logger.info('some fixed string', { some: 'meta object' });
logger.warn('some fixed string', { some: 'meta object' });
logger.error('some fixed string', { some: 'meta object' });
It writes all logs to stderr. If you call logger.error()
or
logger.fatal()
it will throw exceptions. any error callsites
are bugs.
warns go to stderr by default.
You can use the .whitelist()
and .items()
method to make
testing easier
var DebugLogtron = require('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();
assert.equal(items.filter(function (x) {
return x.levelName === 'error'
}).length, 1, 'thing writes to logger.error()');
assert.end();
});
This library will re throw
any .error()
or .fatal()
callsites.
Any warns and infos got to stderr.
Any debugs / access can be made visible using
NODE_DEBUG=mylibrary
.
You can turn colors off with --color false
If you want to see trace() logs you must set NODE_DEBUG=mylibrary TRACE=1
Warning: This a logger for testing! Not a default logger.
If you want to add a default logger to your dependencies
then I strongly recommend you use null-logtron
You want to instrument your application and your libraries with a production application logger. A logger that writes somewhere in production.
However for your writing tests for both your libraries and your applications you probably do not want to see all of your logs spewing on STDOUT by default.
This is where debug-logtron
comes in, You can start your app
or libraries with the debug logger in your tests which allows
the test runner to decide when to spew.
This works great together with itape --trace
where you can
use itape
to turn on and off trace mode.
// TODO. State what the module does.
npm install debug-logtron
npm test
FAQs
A debug logger with a logtron interface.
The npm package debug-logtron receives a total of 175 weekly downloads. As such, debug-logtron popularity was classified as not popular.
We found that debug-logtron 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.