Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
egg-logger
Advanced tools
Egg logger.
Including two base class, Logger
and Transport
:
$ npm i egg-logger
Create a Logger
and add a file Transport
.
const Logger = require('egg-logger').Logger;
const FileTransport = require('egg-logger').FileTransport;
const ConsoleTransport = require('egg-logger').ConsoleTransport;
const logger = new Logger();
logger.set('file', new FileTransport({
file: '/path/to/file',
level: 'INFO',
}));
logger.set('console', new ConsoleTransport({
level: 'DEBUG',
}));
logger.debug('debug foo'); // only output to stdout
logger.info('info foo');
logger.warn('warn foo');
logger.error(new Error('error foo'));
logger.disable('file');
logger.info('info'); // output nothing
logger.enable('file');
logger.info('info'); // output 'info' string
Redirect error log to other logger.
logger.redirect('error', errorLogger);
logger.error(new Error('print to errorLogger')); // equal to `errorLogger.error`
Write to both loggers:
logger.redirect('error', errorLogger, { duplicate: true });
logger.reload(); // will close the exists write stream and create a new one.
You can make your own Transport
for logging,e.g.: send log to your logging server.
const urllib = require('urllib');
const Transport = require('egg-logger').Transport;
class UrllibTransport extends Transport {
log(level, args, meta) {
const msg = super.log(level, args, meta);
return urllib.request('url?msg=' + msg);
}
}
const logger = new Logger();
logger.set('remote', new UrllibTransport({
level: 'DEBUG',
}));
logger.info('info');
FAQs
egg logger
The npm package egg-logger receives a total of 29,766 weekly downloads. As such, egg-logger popularity was classified as popular.
We found that egg-logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 14 open source maintainers 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.