New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

callback-logger

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

callback-logger

Log callback results

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

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

callback-logger

Log callback results

Installation

npm install callback-logger

Usage

CallbackLogger(options)

Supported options:

  • successColor - (default: 'green') Color for success messages. See cli-color for a list of supported colors
  • errorColor - (default: 'red') Color for error messages
  • logFunction - (default: console.log) Function to call to log a message. It should be of the form function(message)
  • traceErrors - (default: true) When an error occurs, append the error stack to the message

logger.success(message)

Log a message as a success

logger.error(message, err)

Log a message as an error. If err is passed and options.traceErrors is true, the stack trace will also be logged.

logger.cb(successMessage, errorMessage, callback)

Return a function which logs the result of a callback of type (err, success). If err is defined, errorMessage is used, otherwise successMessage is used.

Underscore templating may be used on successMessage and errorMessage. The variables err and res contain the result of the callback

An optional callback can be passed which is executed after the log messages.

Example

var logger = require('callback-logger')();

fs.writeFile('file.txt', 'contents', logger.cb('Successfully wrote file', 'Error while writing file'));

glob('*.txt', logger.cb('Found <%= res.length %> files', 'Error on glob'));

logger.success('Done something');
logger.error('Something went wrong');

FAQs

Package last updated on 15 Apr 2014

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