
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Simple Javascript logger for Node.js and Browsers
DEMO Open the dev tools to see the log output
logplease does two simple things: output log messages to the console and to a file (Node.js only). Inspired by log4js and debug.
npm install logplease
npm run example
Open example/index.html
in your browser.
const Logger = require('logplease');
// Create loggers, see 'options' below for details
const logger1 = Logger.create('daemon', { filename: 'debug.log', useColors: false, appendFile: true });
const logger2 = Logger.create('utils', { color: Logger.Colors.Yellow });
const logger3 = Logger.create('logger3', { color: Logger.Colors.Magenta, showTimestamp: false, showLevel: false });
// Set global log level
Logger.setLogLevel(Logger.LogLevel.INFO)
// CAVEAT: log functions can't take any parameters. If you need params, use string interpolation.
const number = 5;
logger1.debug(`This is a log message #${number}`);
logger1.info(`This is a log message #${number}`);
logger1.warn(`This is a log message #${number}`);
logger1.error(`This is a log message #${number}`);
logger2.debug(`This is a log message #${number}`);
logger2.info(`This is a log message #${number}`);
logger2.warn(`This is a log message #${number}`);
logger2.error(`This is a log message #${number}`);
logger3.debug(`This is a log message #${number}`);
logger3.info(`This is a log message #${number}`);
logger3.warn(`This is a log message #${number}`);
logger3.error(`This is a log message #${number}`);
Copy dist/logplease.min.js
to your javascripts directory and include it in your html. See example/index.html for details.
<body>
<script type="text/javascript" src="logplease.min.js" charset="utf-8"></script>
<script type="text/javascript">
var logger = Logger.create('logger name');
logger.debug(`This is a log message`);
logger.info(`This is a log message`);
logger.warn(`This is a log message`);
logger.error(`This is a log message`);
</script>
</body>
You can set a global log level to display only the wanted log messages.
const Logger = require('logplease');
Logger.setLogLevel(Logger.LogLevel.ERROR) // Show only ERROR messages
// or
Logger.setLogLevel('ERROR')
Log levels:
DEBUG
INFO
WARN
ERROR
NONE
You can set a color per logger.
const Logger = require('logplease');
const logger = Logger.create("logger name", { color: Logger.Colors.Yellow });
Colors:
Black, Red, Green, Yellow, Blue, Magenta, Cyan, Grey, White
You can customize your logger.
const Logger = require('logplease');
const logger = Logger.create("logger name", options);
Available options and defaults:
const options = {
useColors: true, // Enable colors
color: Colors.White, // Set the color of the logger
showTimestamp: true, // Display timestamp in the log message
showLevel: true, // Display log level in the log message
filename: null, // Set file path to log to a file
appendFile: true, // Append logfile instead of overwriting
};
Install build dependencies:
npm install
The build command will build the browser distributable. Note that for Node.js it is not needed to run the build command.
npm run build:dist
The distributable file will be located in dist/logplease.min.js
Build the browser example:
npm run build_examples
FAQs
Simple Javascript logger for Node.js and Browsers
The npm package logplease receives a total of 12,724 weekly downloads. As such, logplease popularity was classified as popular.
We found that logplease 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.