loglevel-mixin
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -155,2 +155,6 @@ /* jslint node: true, esnext: true */ | ||
} else { | ||
if(arg === undefined) { | ||
return Object.assign(logevent, args); | ||
} | ||
if (arg instanceof Error && arg.stack) { | ||
@@ -157,0 +161,0 @@ logevent.stack = arg.stack.split(/\n/).map(l => l.trim()); |
@@ -42,3 +42,3 @@ { | ||
}, | ||
"version": "1.4.0" | ||
"version": "1.4.1" | ||
} |
/* global describe, it*/ | ||
/* jslint node: true, esnext: true */ | ||
"use strict"; | ||
'use strict'; | ||
@@ -13,8 +13,7 @@ const chai = require('chai'), | ||
describe('logging with classes', function () { | ||
describe('logging with classes', () => { | ||
let theValue = 0; | ||
let theLevel = "none"; | ||
let theLevel = 'none'; | ||
class BaseClass {} | ||
@@ -36,8 +35,8 @@ | ||
it('default info', function () { | ||
assert.equal(someObject.logLevel, "info"); | ||
assert.equal(someObject.logLevel, 'info'); | ||
}); | ||
it('set invalid fallback info', function () { | ||
someObject.logLevel = "unknown"; | ||
assert.equal(someObject.logLevel, "info"); | ||
someObject.logLevel = 'unknown'; | ||
assert.equal(someObject.logLevel, 'info'); | ||
}); | ||
@@ -54,4 +53,4 @@ | ||
someOtherObject.logLevel = 'trace'; | ||
assert.equal(someOtherObject.logLevel, "trace"); | ||
assert.equal(someObject.logLevel, "info"); | ||
assert.equal(someOtherObject.logLevel, 'trace'); | ||
assert.equal(someObject.logLevel, 'info'); | ||
}); | ||
@@ -62,3 +61,3 @@ }); | ||
it('info passes', function () { | ||
someObject.info(level => "info message"); | ||
someObject.info(level => 'info message'); | ||
assert.equal(theValue, 'info message'); | ||
@@ -68,3 +67,3 @@ assert.equal(theLevel, 'info'); | ||
it('trace ignored', function () { | ||
someObject.trace(level => "trace message"); | ||
someObject.trace(level => 'trace message'); | ||
assert.equal(theValue, 'info message'); | ||
@@ -74,3 +73,3 @@ assert.equal(theLevel, 'info'); | ||
it('error passes', function () { | ||
someObject.error("error message"); | ||
someObject.error('error message'); | ||
assert.equal(theValue, 'error message'); | ||
@@ -77,0 +76,0 @@ assert.equal(theLevel, 'error'); |
/* global describe, it*/ | ||
/* jslint node: true, esnext: true */ | ||
"use strict"; | ||
'use strict'; | ||
@@ -13,6 +13,6 @@ const chai = require('chai'), | ||
describe('logging', function () { | ||
describe('logging', () => { | ||
let theValue = 0; | ||
let theLevel = "none"; | ||
let theLevel = 'none'; | ||
@@ -27,3 +27,2 @@ const someObject = {}; | ||
llm.defineLoggerMethods(someObject, llm.defaultLogLevels, function (level, message) { | ||
@@ -40,8 +39,8 @@ theLevel = level; | ||
it('default info', function () { | ||
assert.equal(someObject.logLevel, "info"); | ||
assert.equal(someObject.logLevel, 'info'); | ||
}); | ||
it('set invalid fallback info', function () { | ||
someObject.logLevel = "unknown"; | ||
assert.equal(someObject.logLevel, "info"); | ||
someObject.logLevel = 'unknown'; | ||
assert.equal(someObject.logLevel, 'info'); | ||
}); | ||
@@ -58,4 +57,4 @@ | ||
someOtherObject.logLevel = 'trace'; | ||
assert.equal(someOtherObject.logLevel, "trace"); | ||
assert.equal(someObject.logLevel, "info"); | ||
assert.equal(someOtherObject.logLevel, 'trace'); | ||
assert.equal(someObject.logLevel, 'info'); | ||
}); | ||
@@ -66,3 +65,3 @@ }); | ||
it('info passes', function () { | ||
someObject.info(level => "info message"); | ||
someObject.info(level => 'info message'); | ||
assert.equal(theValue, 'info message'); | ||
@@ -72,3 +71,3 @@ assert.equal(theLevel, 'info'); | ||
it('trace ignored', function () { | ||
someObject.trace(level => "trace message"); | ||
someObject.trace(level => 'trace message'); | ||
assert.equal(theValue, 'info message'); | ||
@@ -78,3 +77,3 @@ assert.equal(theLevel, 'info'); | ||
it('error passes', function () { | ||
someObject.error("error message"); | ||
someObject.error('error message'); | ||
assert.equal(theValue, 'error message'); | ||
@@ -81,0 +80,0 @@ assert.equal(theLevel, 'error'); |
@@ -14,46 +14,65 @@ /* global describe, it*/ | ||
describe('makeLogEvent', () => { | ||
describe('plain', () => { | ||
const le = llm.makeLogEvent("error", "the message"); | ||
it("has timestamp", () => assert.closeTo(le.timestamp, Date.now(), 100)); | ||
it("has level", () => assert.equal(le.level, "error")); | ||
it("has message", () => assert.equal(le.message, "the message")); | ||
const le = llm.makeLogEvent('error', 'the message'); | ||
it('has timestamp', () => assert.closeTo(le.timestamp, Date.now(), 100)); | ||
it('has level', () => assert.equal(le.level, 'error')); | ||
it('has message', () => assert.equal(le.message, 'the message')); | ||
}); | ||
describe('empty', () => { | ||
const le = llm.makeLogEvent('error'); | ||
it('has timestamp', () => assert.closeTo(le.timestamp, Date.now(), 100)); | ||
it('has level', () => assert.equal(le.level, 'error')); | ||
it('undefined message', () => assert.isUndefined(le.message)); | ||
}); | ||
describe('error object', () => { | ||
describe('direct', () => { | ||
const le = llm.makeLogEvent('error', new Error('the error')); | ||
it('has stack', () => assert.isArray(le.stack)); | ||
}); | ||
describe('indirect', () => { | ||
const le = llm.makeLogEvent('error', { | ||
error: new Error('the error') | ||
}); | ||
it('has stack', () => assert.isArray(le.stack)); | ||
}); | ||
}); | ||
describe('overwrite timestamp', () => { | ||
const le = llm.makeLogEvent("error", { | ||
const le = llm.makeLogEvent('error', { | ||
timestamp: 1234, | ||
message: "the message" | ||
message: 'the message' | ||
}); | ||
it("has timestamp", () => assert.closeTo(le.timestamp, 1234, 100)); | ||
it("has level", () => assert.equal(le.level, "error")); | ||
it("has message", () => assert.equal(le.message, "the message")); | ||
it('has timestamp', () => assert.closeTo(le.timestamp, 1234, 100)); | ||
it('has level', () => assert.equal(le.level, 'error')); | ||
it('has message', () => assert.equal(le.message, 'the message')); | ||
}); | ||
describe('with additional object', () => { | ||
const le = llm.makeLogEvent("error", "the message", { | ||
"key1": "value1" | ||
const le = llm.makeLogEvent('error', 'the message', { | ||
key1: 'value1' | ||
}); | ||
it("has timestamp", () => assert.closeTo(le.timestamp, Date.now(), 100)); | ||
it("has level", () => assert.equal(le.level, "error")); | ||
it("has message", () => assert.equal(le.message, "the message")); | ||
it("has additional values", () => assert.equal(le.key1, "value1")); | ||
it('has timestamp', () => assert.closeTo(le.timestamp, Date.now(), 100)); | ||
it('has level', () => assert.equal(le.level, 'error')); | ||
it('has message', () => assert.equal(le.message, 'the message')); | ||
it('has additional values', () => assert.equal(le.key1, 'value1')); | ||
}); | ||
describe('object and additional object', () => { | ||
const le = llm.makeLogEvent("error", { | ||
"message": "the message", | ||
"key2": "value2", | ||
"key3": "value2" | ||
const le = llm.makeLogEvent('error', { | ||
message: 'the message', | ||
key2: 'value2', | ||
key3: 'value2' | ||
}, { | ||
"key1": "value1", | ||
"key3": "value3" | ||
key1: 'value1', | ||
key3: 'value3' | ||
}); | ||
it("has timestamp", () => assert.closeTo(le.timestamp, Date.now(), 100)); | ||
it("has level", () => assert.equal(le.level, "error")); | ||
it("has message", () => assert.equal(le.message, "the message")); | ||
it("has additional values 1", () => assert.equal(le.key1, "value1")); | ||
it("has additional values 2", () => assert.equal(le.key2, "value2")); | ||
it("has additional values 3", () => assert.equal(le.key3, "value3")); | ||
it('has timestamp', () => assert.closeTo(le.timestamp, Date.now(), 100)); | ||
it('has level', () => assert.equal(le.level, 'error')); | ||
it('has message', () => assert.equal(le.message, 'the message')); | ||
it('has additional values 1', () => assert.equal(le.key1, 'value1')); | ||
it('has additional values 2', () => assert.equal(le.key2, 'value2')); | ||
it('has additional values 3', () => assert.equal(le.key3, "value3")); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18091
331