Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

xxd-log

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xxd-log

Simple console logger with colors and levels.

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

Usage

const log = require('xxd-log');

// Different log levels
// Accept same arguments as `console.log()`
const count = 5;
log.trace('count: %d', count);
log.debug('count:', count);
log.info(`count: ${count}`);
log.warn({count});
log.error(new Error(`count (${count}) is wrong.`));
log.fatal('Duang!');

// Use chalk directly
console.log(log.chalk.red('This is red.'));

Configure

// Change options of the default logger instance.

log.withLabel = false; // Do not display labels before messages.
log.withTimestamp = false; // Do not display current time before messages.
log.highlightStackTrace = false; // Do not highlight key positions in error stack trace.
log.timestampFormat = 'HH:mm:ss.SSS'; // Customize the time format.

log.withLabel = log.newLogger().options.withLabel; // reset an option.
// Use an individual instance with different options

const anotherLogger = log.newLogger({
  withLabel: false,
  withTimestamp: false,
  highlightStackTrace: false,
})

You can change these options at any time in the process, and will take effect from next call of logging.

For further instruction of time format, please see moment.js documentation

Options List

OptionTypeDescription
withTimestampbooleanControl if print message with timestamp before, default to true
withLabelbooleanControl if print message with label (indicating log level) before, default to true
timestampFormatstringDefine how timestamp looks like, see moment.format() (http://momentjs.com/docs/#/displaying/format/), default to 'YYYY-MM-SS HH:mm:ss'
highlightStackTracestringControl if highlight files in project (in process.cwd(), and not in node_modules) in error stack trace. default to true

Requirements

  • Node.js > 6.0.0
  • or Node.js > 4.0.0 with --harmony

Keywords

FAQs

Package last updated on 31 Jul 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc