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.2 to 1.2.3

coverage/coverage.json

63

index.js

@@ -1,7 +0,60 @@

var dir = './lib/';
if (process.env.LOGDRIVER_COVERAGE){
dir = './lib-cov/';
}
var util = require('util');
module.exports = require(dir + 'index');
LogDriver = function(options){
options = options || {};
var logger = this;
if (options.format){
this.format = options.format;
}
this.levels = options.levels || ['error', 'warn', 'info', 'debug', 'trace'];
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 (logLevelShouldOutput(level, logger.level, logger.levels)){
logger[level] = function(){
var args = Array.prototype.slice.call(arguments);
args.unshift(level); // log level is added as the first parameter
console.log(logger.format.apply(logger, args));
};
} else {
logger[level] = function(){/* no-op, because this log level is ignored */};
}
});
};
var logLevelShouldOutput = function(logLevel, configuredLevel, levels){
if (configuredLevel === false){
return false;
}
return (levels.indexOf(logLevel) <= levels.indexOf(configuredLevel));
};
LogDriver.prototype.format = function(){
var args = Array.prototype.slice.call(arguments, [1]); // change arguments to an array, but
// drop the first item (log level)
var out = "[" + arguments[0] + "] " + JSON.stringify(new Date()) + " ";
args.forEach(function(arg){
out += " " + util.inspect(arg);
});
return out;
};
var defaultLogger = null;
factory = function(options){
defaultLogger = new LogDriver(options);
factory.logger = defaultLogger;
return defaultLogger;
};
factory();
module.exports = factory;

72

package.json
{
"name": "log-driver",
"description" : "log-driver is a simple logging framework for logging to stdout",
"keywords" : ["logging", "logger", "log"],
"version": "1.2.2",
"bugs": {
"url": "https://github.com/cainus/logdriver/issues"
},
"repository" : {
"type": "git",
"url": "git://github.com/cainus/logdriver.git"
},
"scripts" : {
"test" : "make test-coveralls"
},
"maintainers": [
{
"name": "Gregg Caines",
"email": "gregg@caines.ca",
"web": "http://caines.ca"
}
],
"dependencies": {
},
"devDependencies" : {
"jscoverage" : "0.3.6",
"sinon-restore" : "1.0.0",
"coveralls": "1.1.0",
"mocha" : "1.8.1",
"should" : "1.1.0"
},
"engines" : {
"node" : ">=0.8.6",
"npm" : "1.1.65"
}
"name": "log-driver",
"description": "log-driver is a simple logging framework for logging to stdout",
"keywords": [
"logging",
"logger",
"log"
],
"version": "1.2.3",
"bugs": {
"url": "https://github.com/cainus/logdriver/issues"
},
"repository": {
"type": "git",
"url": "git://github.com/cainus/logdriver.git"
},
"scripts": {
"test": "make test-coveralls"
},
"maintainers": [
{
"name": "Gregg Caines",
"email": "gregg@caines.ca",
"web": "http://caines.ca"
}
],
"dependencies": {
},
"devDependencies": {
"jshint": "2.4.4",
"istanbul": "0.2.6",
"coveralls": "2.10.0",
"sinon-restore": "1.0.0",
"mocha": "1.8.1",
"should": "1.1.0"
},
"engines": {
"node": ">=0.8.6"
}
}

@@ -1,7 +0,4 @@

![Log Driver](https://raw.github.com/cainus/logdriver/master/logo.png)
![Log Driver][logdriver-logo]
=========
[![Build
Status](https://travis-ci.org/cainus/logdriver.png?branch=master)](https://travis-ci.org/cainus/logdriver)
[![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)
[![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![NPM Version][npm-image]][npm-url]

@@ -43,4 +40,4 @@ Logdriver is a node.js logger that only logs to stdout.

var logger = require('log-driver')({
levels : ['superimportant', 'checkthisout', 'whocares' ]
})
levels: ['superimportant', 'checkthisout', 'whocares' ]
});
logger.whocares("brangelina in lover's quarrel!");

@@ -51,3 +48,3 @@ ```

```javascript
var logger = require('log-driver')({ level : "info" });
var logger = require('log-driver')({ level: "info" });
logger.info("info test");

@@ -70,3 +67,3 @@ logger.warn("warn test");

```javascript
var logger = require('log-driver')({ level : false });
var logger = require('log-driver')({ level: false });
```

@@ -87,3 +84,3 @@

var logger = require('log-driver')({
format : function(){
format: function() {
// let's do pure JSON:

@@ -95,3 +92,13 @@ return JSON.stringify(arguments);

![Log Driver](https://raw.github.com/cainus/logdriver/master/waltz.jpg)
![Log Driver](https://raw.github.com/cainus/logdriver/master/waltz.jpg)
[logdriver-logo]: https://raw.github.com/cainus/logdriver/master/logo.png
[travis-image]: https://travis-ci.org/cainus/logdriver.png?branch=master
[travis-url]: https://travis-ci.org/cainus/logdriver
[coveralls-image]: https://coveralls.io/repos/cainus/logdriver/badge.png?branch=master
[coveralls-url]: https://coveralls.io/repos/cainus/logdriver
[npm-image]: https://badge.fury.io/js/log-driver.png
[npm-url]: https://badge.fury.io/js/log-driver

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