
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.
Lightweight colorful JavaScript application logger with stack trace and logfile support for node.js
#Clrlog# ##Lightweight colorful JavaScript application logger with stack trace and logfile support for node.js##

#Changes in version 1.6#
#Changes in version 1.4#
##Log level changes##
Now the default log level is error & warning. Log message and success is disabled by default. It can be enabled again by setting the logLevel (logLevel='error,warning,success,message')
Any log message can be enabled temporary by
##Activation switch changes##
Clrlog has now a new property inside the constructor.
An env variable (process.env.CUSTOM_VARIALBE) can be registered (e.g by starting the node app CUSTOM_VARIALBE=true node app.js )
which enables any log level in the specific context for a better app behave logging.
#How to use# Instal Clrlog via npm
npm install clrlog
Require the Clrlog class
var Clrlog = require('clrlog');
To give log messages color set global.DEBUG=true or run application in node.js's debug mode
process.env.DEBUG = true; // or on startup DEBUG=true node app.js
Or create a file named debug in applications root folder
Clrlog can be used as a function
Clrlog("Hello I'm Clrlog");
Or as an object of the Clrlog class (The logger can be registered to a process.env property to enable logging for different purposes)
var myClrlog = new Clrlog("I support logging into logfiles too", 'success', __dirname + '/application.log', 'MY_CUSTOM_LOG');
myClrlog.logLevel = 'error';
myClrlog.warning('This line is not written into logfile');
myClrlog.error('This line is written into logfile');
Set custom log levels for a single logmessage type
myClrlog.logLevel = 'error';
Or set log levels for multiple log message types
myClrlog.logLevel = 'error,warning,success';
The logs are stored in the following format
Sat Apr 05 2014 [...] | SUCCESS ᑀ And hold log instances for more complex logging purposes
Sat Apr 05 2014 [...] | SUCCESS ᑀ The current loglevel is message,success
Sat Apr 05 2014 [...] | MESSAGE ᑀ This message goes into the logfile
Sat Apr 05 2014 [...] | SUCCESS ᑀ This line goes into the logfile too
Sat Apr 05 2014 [...] | SUCCESS ᑀ {
"I": "can",
"log": "Objects too"
}
#Full working example (demo/demo.js)#
(function () {
"use strict";
// Enable global.DEBUG for colorful logging purposes
// OR colorize logging when node is started in debug mode
// global.DEBUG = true;
//
// A file named debug was created in applications root folder
// so global.DEBUG is automatically set to true
// Fetch Clrlog
var Clrlog = require(__dirname + '/../index.js');
////////////////////////////////////////////////////////
/////Call Clrlog like a plain old javascript funtion/////
////////////////////////////////////////////////////////
Clrlog("Hello I'm Clrlog");
Clrlog("I was successful", 'success');
Clrlog("I've need to warn you ", 'warning');
Clrlog("I've made a mistake", 'error');
// Object Logging
Clrlog({
I: 'can',
log: 'Objects too'
}, 'success');
// Save log messages in a file
Clrlog("And I can store my logs into a file", 'message', __dirname + '/example.log');
// Show stack trace behind logmessage
Clrlog("My logs can also include a detailed stack trace", 'success', false, true);
////////////////////////////////////////////////////////
/////Call Clrlog as an object for more comples stuff/////
////////////////////////////////////////////////////////
var myClrlog = new Clrlog("And hold log instances for more complex logging purposes", 'success', __dirname + '/application.log');
// LogLevel can be set on custom purposes
myClrlog.logLevel = 'error'; // Only errormessages
myClrlog.logLevel = 'warning'; // Only warnings
myClrlog.logLevel = 'success'; // Only success
myClrlog.logLevel = 'message'; // Only messages
// Combined log levels are possble too
myClrlog.logLevel = 'error,warning';
myClrlog.logLevel = 'error,warning,success';
myClrlog.logLevel = 'message,success';
// Loglevel settings example
myClrlog.logLevel = 'message,success';
myClrlog.success('The current loglevel is ' + myClrlog.logLevel);
myClrlog.message('This message goes into the logfile');
myClrlog.error('This line is not written into logfile');
myClrlog.success('This line goes into the logfile too');
})();
Author: Clrlog was written by Bernhard Bezdek
Released under MIT License
###Dependencies### node.js file system api
FAQs
Lightweight colorful JavaScript application logger with stack trace and logfile support for node.js
We found that clrlog 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.