
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
universal-log
Advanced tools
Flexible logger for Node.js and the browser.
npm install --save universal-log
import UniversalLog from 'universal-log';
let logger = new UniversalLog({ appName: 'example' });
logger.info('Little info');
logger.error('There is something wrong');
There are 10 levels of logging: silence, trace, debug, info, notice, warning, error, critical, alert and emergency.
Depending on the type of output, a level can have an effect on the way a log message is formated. For example, the ConsoleOutput uses different colors for each levels.
A muteLevels option allows to mute some levels. By default, the silence level is muted. The trace and debug levels are also muted when NODE_ENV is undefined or equal to 'development'.
You can configure where you want to output your log messages.
For now, the supported outputs are:
ConsoleOutput writes logs to Node.js or browser console.RemoteOutput sends logs to a UniversalLogServer.AWSCloudWatchLogsOutput sends logs to AWS CloudWatch Logs.It is easy to create your own type of output. An output is just an object with a write(logName, hostName, level, message) method. See an example of custom output.
new UniversalLog([options])Create a logger.
import UniversalLog from 'universal-log';
let logger = new UniversalLog({ appName: 'example' });
optionslogName: the name of the log. If not specified, the name is a combination of appName and NODE_ENV.appName: the name of the running application.hostName: the name of the host where the application is running. If not specified, hostName is determined from the hostname of the machine. If the application is running in a browser, hostName defaults to 'browser'.outputs: the outputs where all the logging goes. The default is an instance of ConsoleOutput.muteLevels: mute the specified levels. By default, the silence level is muted. The trace and debug levels are also muted when NODE_ENV is undefined or equal to 'development'.decorators: a simple way to "decorate" log messages. A decorator is a function receiving a string (a log message) and returning a string (the decorated log message). Decorators are useful to add some contextual information to log messages. For example, a decorator could be used to add the name of the current user.logger.log(level, messsage)Log a message with the specified level.
logger.log('info', 'Little info');
logger.log('warning', 'There is something wrong');
logger.{level}(messsage)Convenient shorthand methods to log messages for a specific level.
logger.debug('Little info');
logger.error('There is something wrong');
logger.warning('Be careful, something is happening');
logger.createTimer([label])Measure and log the time passed doing something.
let timer = logger.createTimer('Heavy computation');
// ...
timer.stop();
logger.addOutput(output)Add an output to the logger.
import { RemoteOutput } from 'universal-log';
logger.addOutput(new RemoteOutput('http://api.example.com/v1'));
logger.addDecorator(decorator)Add a decorator to the logger.
logger.addDecorator(function(message) {
return message + ` (current user: ${username})`;
});
Who cares?
FAQs
Flexible logger for Node.js and the browser
The npm package universal-log receives a total of 1 weekly downloads. As such, universal-log popularity was classified as not popular.
We found that universal-log 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.