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

log-driver

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

log-driver - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

somelog.log

23

lib/index.js

@@ -10,10 +10,14 @@ var util = require('util');

this.levels = options.levels || ['error', 'warn', 'info', 'debug', 'trace'];
this.level = options.level || this.levels[this.levels.length - 1];
if (this.levels.indexOf(this.level) === -1){
throw new Error("Log level '" +
this.level +
"' does not exist in level list '" + JSON.stringify() + "'");
if (options.level === false){
this.level = false; // don't log anything
} else {
this.level = options.level || this.levels[this.levels.length - 1];
if (this.levels.indexOf(this.level) === -1){
throw new Error("Log level '" +
this.level +
"' does not exist in level list '" + JSON.stringify() + "'");
}
}
this.levels.forEach(function(level){
if (logger.levels.indexOf(level) <= logger.levels.indexOf(logger.level)){
if (logLevelShouldOutput(level, logger.level, logger.levels)){
logger[level] = function(){

@@ -30,2 +34,9 @@ var args = Array.prototype.slice.call(arguments);

var logLevelShouldOutput = function(logLevel, configuredLevel, levels){
if (configuredLevel === false){
return false;
}
return (levels.indexOf(logLevel) <= levels.indexOf(configuredLevel));
};
LogDriver.prototype.format = function(){

@@ -32,0 +43,0 @@ var args = Array.prototype.slice.call(arguments, [1]); // change arguments to an array, but

@@ -5,3 +5,3 @@ {

"keywords" : ["logging", "logger", "log"],
"version": "1.2.0",
"version": "1.2.1",
"bugs": {

@@ -8,0 +8,0 @@ "url": "https://github.com/cainus/logdriver/issues"

@@ -6,2 +6,3 @@ ![Log Driver](https://raw.github.com/cainus/logdriver/master/logo.png)

[![Coverage Status](https://coveralls.io/repos/cainus/logdriver/badge.png?branch=master)](https://coveralls.io/r/cainus/logdriver)
[![NPM version](https://badge.fury.io/js/logdriver.png)](http://badge.fury.io/js/logdriver)

@@ -65,2 +66,8 @@ Logdriver is a node.js logger that only logs to stdout.

Turning off all log output (sometimes nice for automated tests to keep
output clean):
```javascript
var logger = require('log-driver')({ level : false });
```
Using the same logger everywhere:

@@ -67,0 +74,0 @@ The last logger you created is always available this way:

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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