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

elecpen

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elecpen - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

.eslintrc

52

lib/index.js

@@ -27,2 +27,11 @@ 'use strict';

function isDefined(v) {
// filter `null` and `void 0`
return v !== null;
}
function isDev() {
return process.env['NODE_ENV'] !== 'production';
}
/**

@@ -32,12 +41,14 @@ * Main method for create logger. The logger is just a function to recieve

*
* @param {Writable} writable A writable stream for logging
* @param {string} prefix The prefix to write
* @param {string | bool} date The date format
* @param {Writable} writable A writable stream for logging
* @param {string} prefix The prefix to write
* @param {string | bool} date The date format
* @return {function} A function use like `console.log`
*/
function createLogger(writable, prefix, dateFormat) {
if (!(writable && typeof writable.write === 'function')) {
throw Error("The logger expected a writable stream.");
}
function createLogger(writables, prefix, dateFormat) {
if (!Array.isArray(writables)) writables = [writables];
writables = writables.filter(function (w) {
return isDefined(w) && isFunction(w.write);
});
var pre = '[' + prefix + ']';

@@ -51,3 +62,5 @@ // default timestamp format

return function (msg) {
writable.write(pre + ' ' + msg + '\n');
writables.forEach(function (w) {
return w.write(pre + ' ' + msg + '\n');
});
};

@@ -78,2 +91,9 @@ }

// The value of `logToConsole` default to true in dev mode
var logToConsole = opts.logToConsole;
if (isDev() && !isDefined(logToConsole)) {
logToConsole = true;
}
var flag = append ? 'a' : 'w';

@@ -91,3 +111,5 @@ var infoStream = infoFile && _fs2.default.createWriteStream(infoFile, { flags: flag });

});
stream && createLogger(stream, 'Verbose', timestamp).apply(this, arguments);
if (logToConsole) stream = [process.stdout, stream];
createLogger(stream, 'Verbose', timestamp).apply(this, arguments);
},

@@ -98,3 +120,5 @@ info: function info() {

});
stream && createLogger(stream, 'Info', timestamp).apply(this, arguments);
if (logToConsole) stream = [process.stdout, stream];
createLogger(stream, 'Info', timestamp).apply(this, arguments);
},

@@ -105,3 +129,5 @@ warning: function warning() {

});
stream && createLogger(stream, 'Warning', timestamp).apply(this, arguments);
if (logToConsole) stream = [process.stderr, stream];
createLogger(stream, 'Warning', timestamp).apply(this, arguments);
},

@@ -112,3 +138,5 @@ error: function error() {

});
stream && createLogger(stream, 'Error', timestamp).apply(this, arguments);
if (logToConsole) stream = [process.stderr, stream];
createLogger(stream, 'Error', timestamp).apply(this, arguments);
}

@@ -115,0 +143,0 @@ };

{
"name": "elecpen",
"version": "0.2.2",
"version": "0.2.3",
"description": "a simple logger",

@@ -31,7 +31,9 @@ "main": "lib/index.js",

"babel-cli": "^6.4.0",
"babel-eslint": "^5.0.0-beta6",
"babel-preset-es2015": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"babel-register": "^6.3.13",
"eslint": "^1.10.3",
"mocha": "^2.2.5"
}
}

@@ -14,3 +14,3 @@ # ElecPen

|-----|-----------|
|writable|A writable stream for logging|
|writables|One or an array of writable stream for logging|
|prefix|The prefix of the record|

@@ -31,2 +31,3 @@ |dateFormat|Date format for logger or pass `true` to use the default format|

|append|boolean|If file exists, append new entries to it instead of truncating|
|logToConsole|boolean|Output the message to console, it will be default to true in dev mode|

@@ -33,0 +34,0 @@ ### Methods

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