Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@reallyuseful/logger
Advanced tools
A simple and extensible logging system for Node.js.
👷 Under development
const { Logger } = require('@reallyuseful/logger');
const myLogger = new Logger();
myLogger.info('🌍 Hello, world!');
myLogger.err('💥 An error occurred.', { context: 42 });
You can log to multiple services at once.
ConsoleTransport
Transport
is easyEach logging function returns a Promise
that is resolved once all the transports have finished logging.
const logger = new Logger([array of Transports]);
ConsoleTransport
.logger.debug(…);
logger.info(…);
logger.notice(…);
logger.warning(…);
logger.err(…);
logger.crit(…);
logger.alert(…);
logger.emerg(…);
You can pass anything as arguments to these functions. It’s common to pass a string as the first argument, followed by additional objects that you want to log. (Just like console.log
.)
logger.info(
'This is a string',
{ extraInfo: 42 },
[ 'Gryffindor', 'Hufflepuff', 'Ravenclaw', 'Slytherin' ]
);
ConsoleTransport can be customized with the following options:
true
, console output is colorized. Default: true
true
, console output is prefixed with the current timestamp. Default: true
const transport = new ConsoleTransport({ <options> });
const logger = new Logger(transport);
To log to a service that isn’t listed above, you can create your own Transport
.
A Transport
is any object with the following properties:
log()
methodlevel
property (optional)The log
method takes a severity level as its first argument. Additional arguments are the details to be logged.
The log
method returns a Promise
, and you should not resolve it until logging is complete. For example, if you are logging to a file, don’t resolve the Promise
until the message has been written to disk.
If your transport object has a level
property, this is the minimum severity to be logged. For example if your object has a level
property that is set to Level.warning
, then your transport will receive log messages for warning
, err
, crit
, alert
and emerg
, but not for debug
, info
or notice
.
const verySimpleTransport = {
level: Level.warning,
log: (level, ...details) => {
console.log(Level[level], ...details);
return Promise.resolve();
}
};
FAQs
A useful and simple Node.js logging system.
We found that @reallyuseful/logger 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.