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

simple-color-log

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-color-log - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

11

index.js

@@ -5,3 +5,3 @@ var colors = require('colors');

var methods = {
none: 0,
none: {importance: 0},
error: {color: 'red', bgcolor: 'bgRed', importance: 1},

@@ -12,3 +12,3 @@ info: {color: 'cyan', bgcolor: 'bgCyan', importance: 2},

var options = {
minimumLoggableLevel: 1
maximumLoggableLevel: 1
};

@@ -18,5 +18,5 @@

if (methods[loglevelName]) {
options.minimumLoggableLevel = methods[loglevelName];
options.maximumLoggableLevel = methods[loglevelName].importance;
} else {
options.minimumLoggableLevel = 1;
options.maximumLoggableLevel = 1; // only show errors
}

@@ -30,3 +30,3 @@ }

var d = new Date();
if (options.minimumLoggableLevel > methods[method].importance){
if (options.maximumLoggableLevel < methods[method].importance){
return null;

@@ -51,2 +51,3 @@ }

console.log (msg);
return true;
}

@@ -53,0 +54,0 @@ })(method)

{
"name": "simple-color-log",
"version": "1.0.2",
"version": "1.0.3",
"description": "This is a simple logging function, with colors and timestamps",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -13,4 +13,27 @@ var sinon = require ('sinon');

it ("Also provides setLogLevel method", function () {
assert.equal(typeof(log.setLogLevel), 'function');
assert.equal(typeof log.setLogLevel, 'function');
});
it ('Shows no logs if loglevel is set to none', function () {
log.setLogLevel('none');
var spy = sinon.spy(log, 'debug');
spy('string');
assert(spy.returned(null));
spy.restore();
});
it ('Only shows errors, if loglevel is set on errors', function () {
log.setLogLevel('error');
var spyError = sinon.spy(log, 'error');
var spyInfo = sinon.spy(log, 'info');
var spyDebug = sinon.spy(log, 'debug');
spyError('string');
spyInfo('string');
spyDebug('string');
assert(spyError.returned(true));
assert(spyInfo.returned(null));
assert(spyDebug.returned(null));
spyError.restore();
spyInfo.restore();
spyDebug.restore();
});
})
var log = require ('../index');
log.setLogLevel('debug');
log.info("So this is some info I just made up");
log.debug("So this is some debug I just made up");
log.error("So this is some error I just made up");
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