Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
A light-weight heavily inspired logging library for NodeJS. Checkout the main features:
printf
-like formatting on messages.npm i -P golog
.const GoLog = require('require');
// Crate a new logger.
var log = new GoLog();
// Add a Writable Stream to receive log entries.
log.addStream( 'my-stdout', process.stdout );
// Add a file where to write log entries.
log.addFile( 'my-file', '/path/to/file' );
log.debug('Main log message');
log.info('Main log message');
log.warn('Counting, %d, %d, %d... %s', 1, 2, 3, 'Foo!');
log.error('Main log message');
log.fatal({ merge: 'this', object: 'with', the: 'entry' }, 'The MSG');
If you want to setup a logger with a single stream or file go with the one-liner.
var slog = new GoLog({ stream: process.stdout });
var flog = new GoLog({ file: '/path/to/file' });
If you have many loggers writing to the same stream, name each logger for better visibility.
var l1 = new GoLog({ name: 'log-a', stream: process.stdout });
l1.warn('Hey!');
var l2 = new GoLog({ name: 'log-b', stream: process.stdout });
l2.warn('Ho!');
Default loggers only log entries of level warn
or higher. Change the level for an entire logger.
var log = new GoLog({ level: 'debug', stream: process.stdout });
log.debug('Let\'s go!');
If you need these files right now, just change to a mode with better aesthetics.
var log = new GoLog({ stream: process.stdout });
log.warn('This is an ugly JSON');
log.mode = 'pretty'
log.warn('This is a cute JSON');
log.mode = 'minimal'
log.warn('This is just readable');
If you need to stop logging to a given stream/file just use removeStream
.
var log = new GoLog({ stream: process.stdout });
log.addFile('some-file', '/path/to/file');
log.warn('This goes to stdout and file');
log.removeStream('main');
log.warn('This goes to file only');
log.removeStream('some-file');
log.warn('This goes nowhere');
If you happen to need to setup some listeners.
var log = new GoLog();
log.on('fatal', ent => console.log('Show me once'));
log.on('entry', ent => console.log('Show me twice'));
log.fatal('The fatal entry');
log.debug('The debug entry');
If you want to log some information about an Error
instance, just add it as a key to the data object.
log.warn({ err: new Error('My error') }, 'The message lives on');
GoLog also formats http request objects.
const http = require('http');
const GoLog = require('require');
var log = new GoLog({ stream: process.stdout });
var server = http.createServer(function(req, res){
res.end();
log.warn({ req: req }, 'The message lives on');
}).listen(8765);
http.get('http://localhost:8765');
If you have found any problems with this module, please:
~bug
.We will make sure to take a look when time allows us.
If you wish to get that awesome feature or have some advice for us, please:
~proposal
.If you have spotted any enhancements to be made and is willing to get your hands dirty about it, fork us and submit your merge request so we can collaborate effectively.
FAQs
A light-weight stdout logging library for NodeJS.
The npm package golog receives a total of 570 weekly downloads. As such, golog popularity was classified as not popular.
We found that golog 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.