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

cli-logger

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-logger - npm Package Compare versions

Comparing version 0.5.27 to 0.5.28

test/unit/format.js

56

index.js

@@ -1,8 +0,11 @@

var EventEmitter = require('events').EventEmitter;
var fs = require('fs');
var os = require('os');
var path = require('path'), basename = path.basename;
var util = require('util');
var circular = require('circular');
var merge = require('cli-util').merge;
var EventEmitter = require('events').EventEmitter
, fs = require('fs')
, os = require('os')
, path = require('path'), basename = path.basename
, util = require('util')
, circular = require('circular')
, utils = require('cli-util')
, pedantic = utils.pedantic
, ucfirst = utils.ucfirst
, merge = utils.merge;

@@ -38,2 +41,17 @@ var pkg = require(path.join(__dirname, 'package.json'));

var formatters = {
pedantic: function(record, parameters, format) {
var message = format(record, parameters);
return pedantic(message, this.conf.pedantic || '.');
},
normalize: function(record, parameters, format) {
var message = format(record, parameters);
return ucfirst(pedantic(message, this.conf.pedantic || '.'));
},
capitalize: function(record, parameters, format) {
var message = format(record, parameters);
return ucfirst(message);
},
}
var keys = Object.keys(LEVELS); keys.pop();

@@ -398,2 +416,8 @@ var types = [RAW, STREAM, FILE, CONSOLE];

Logger.prototype.format = function(record, parameters) {
var params = parameters.slice(0);
params.unshift(record.msg);
return util.format.apply(util, params);
}
/**

@@ -414,7 +438,19 @@ * Write the log record to stream(s) or dispatch

var i, target, listeners = this.listeners('write'), json, params, event;
var msg = '' + record.msg, prefix;
var msg = '' + record.msg
, prefix
, conf = this.conf
, formatter;
parameters = parameters || [];
level = level || record.level;
params = parameters.slice(0);
params.unshift(record.msg);
record.msg = util.format.apply(util, params);
formatter = typeof conf.formatter === 'function' ? conf.formatter : null;
if(!formatter) {
formatter = formatter || typeof conf.formatter === 'string'
? formatters[conf.formatter] : null;
}
formatter = formatter || this.format;
record.msg = formatter.call(this, record, params, this.format.bind(this));
//console.log('writing %j', record);

@@ -421,0 +457,0 @@ for(i = 0;i < this.streams.length;i++) {

2

package.json
{
"name": "cli-logger",
"version": "0.5.27",
"version": "0.5.28",
"description": "Logger implementation for command line interfaces",

@@ -5,0 +5,0 @@ "author": "muji <noop@xpm.io>",

@@ -132,2 +132,3 @@ # Logger

see [writers](#writers).
* `formatter`: A formatter function or string formatter name. Supported names are `pedantic`, `capitalize` and `normalize`. Signature is `function(record, parameters, format)`; `record` is the log record about to be written, `parameters` is the message replacement parameters and `format` is the default formatter function bound to the logger instance. Formatter functions are invoked in the scope of the logger.

@@ -134,0 +135,0 @@ If you specify any unknown properties in the configuration then these are considered *persistent fields* and are added to every log record. This is a convenient way to add labels for sub-components to log records.

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