
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
marvin-logger
Advanced tools
Simple, effective, colorful and cross-platform logger for nodejs


marvin-logger is a simple, effective, colorful and cross-platform logger for nodejs which:
npm install --save marvin-logger
Include library and create a logger instance. By default, you'll log only to your console.
var Marvin = require('marvin-logger'),
logger = new Marvin();
To log to file, you have to define the output directory:
var Marvin = require('marvin-logger'),
logger = new Marvin({
logOutputDirectory: './logs'
});
Default log format is {{DATETIME}} {{PID}} {{LOG}} with :
Log format can be specified at init time :
var Marvin = require('marvin-logger'),
logger = new Marvin({
logFormat: '{{DATETIME}} - {{LOG}}'
logOutputDirectory: './logs'
});
Log some debug data :
logger.debug('[debug] message');
logger.debug('Another debug message with object', {foo: 'bar'});
debug() can be replaced with info(), warn(), error(), important() and http(). Every methods use the same syntax as console.log().
You can define a minimal log level by passing the level option to Marvin:
var Marvin = require('marvin-logger'),
logger = new Marvin({
level: 'error',
logOutputDirectory: './logs'
});
In this example, only error(), important() and http() will be able to display information.
important() and http() are always shown. You can use them to display important data like critical states or http access (or what ever you want).
To change log level :
logger.setLogLevel('info'); // level >= INFO
logger.setLogLevel('none'); // only HTTP & IMPORTANT
If the log data begins with brackets ('[...]'), only the text between the brackets will be colorized.
logger.important('[MyApp] Super important log message'); // Only 'MyApp' will be shown in magenta
To use marvin-logger as an expressjs middleware logger:
var express = require('express'),
app = express(),
logger = new Marvin();
app.use(logger.expressMiddleWare());
To filter, you can specify wich string or Regex your messages should match, one filter per log level:
var Marvin = require('marvin-logger'),
logger = new Marvin({
errorFilter: 'my-filter-string',
debugFilter: 'my-filter-regex',
});
Available filters are : debugFilter, infoFilter, warnFilter, errorFilter, importantFilter and httpFilter.
Messages not matching filters are neither written to console nor file.
To change a filter after init :
logger.setDebugFilter(null);
logger.setInfoFilter('my-string');
logger.setWarnFilter('my-string');
logger.setErrorFilter('');
logger.setImportantFilter(/my-[regx]/i);
logger.setHttpFilter(/[^htp]/i);
To use marvin-logger as a singleton insance :
var logger = require('marvin-logger').sharedInstance;
logger.setLogOutputDirectory('logs');
logger.setLogLevel('debug');
mochasupervisor -q -n exit -x mocha -- --reporter=nyansupervisor -w ./index.js,./test -q -n exit -x istanbul -- cover _mochanode ./node_modules/.bin/node-readme| Package | Version | Dev |
|---|---|---|
| colors | ^1.1.2 | ✖ |
| file-stream-rotator | 0.0.7 | ✖ |
| node-json-color-stringify | ^1.1.0 | ✖ |
| on-finished | ^2.3.0 | ✖ |
| on-headers | ^1.0.1 | ✖ |
| express | ^4.14.0 | ✔ |
| istanbul | ^0.4.5 | ✔ |
| mocha | ^3.2.0 | ✔ |
| node-readme | ^0.1.9 | ✔ |
| supertest | ^2.0.1 | ✔ |
| supervisor | ^0.12.0 | ✔ |
Contributions welcome; Please submit all pull requests against the master branch. If your pull request contains JavaScript patches or features, you should include relevant unit tests.
René BIGOT
FAQs
Simple, effective, colorful and cross-platform logger for nodejs
We found that marvin-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.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.