btrz-logger
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "btrz-logger", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A multi-transport logger", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,2 +8,3 @@ "use strict"; | ||
constructor(options) { | ||
options.levels = {debug: 0, info: 1, error: 2, fatal: 3}; | ||
this.logger = logentries.logger(options); | ||
@@ -20,3 +21,3 @@ } | ||
fatal(tokens) { | ||
this.error(tokens); | ||
this.logger.log("error", tokens); | ||
} | ||
@@ -23,0 +24,0 @@ |
@@ -33,6 +33,20 @@ "use strict"; | ||
function buildMessage(level, msg, args, options) { | ||
if (!Array.isArray(args)) { | ||
args = [args]; | ||
let _msg = msg, | ||
_args = args; | ||
if (!_.isString(msg) && _.isString(args)) { | ||
_args = msg; | ||
_msg = args; | ||
} | ||
let serialized = serialize([], args), | ||
if (!_.isString(msg) && !_.isString(args)) { | ||
_args = [msg, args]; | ||
_msg = ""; | ||
} | ||
if (!Array.isArray(_args)) { | ||
_args = [_args]; | ||
} | ||
let serialized = serialize([], _args), | ||
dateParts = getDateParts(), | ||
@@ -43,3 +57,3 @@ tokens = { | ||
level: level, | ||
message: msg, | ||
message: _msg, | ||
serverId: options && options.serverId ? options.serverId : "", | ||
@@ -46,0 +60,0 @@ data: serialized.length > 0 ? serialized : "" |
"use strict"; | ||
describe("console", function () { | ||
let logger; | ||
beforeEach(function () { | ||
let Logger = require("../index").Logger, | ||
ConsoleLogger = require("../index").ConsoleLogger, | ||
LogEntriesLogger = require("../index").LogEntriesLogger, | ||
logger = new Logger(); | ||
LogEntriesLogger = require("../index").LogEntriesLogger; | ||
logger = new Logger(); | ||
logger.addLogger(new ConsoleLogger()); | ||
@@ -15,10 +17,7 @@ logger.addLogger(new LogEntriesLogger({token: "fake-token-here"})); | ||
it("should log to console", function () { | ||
// logger.debug("Hello log", new Error("err")); | ||
// logger.info("Hello info", new Error("err")); | ||
// logger.error("Hello error", new Error("err")); | ||
// logger.fatal("Hello fatal", new Error("err")); | ||
// logger.debug("Hello debug 2", {d: new Date(), some: "info", and: new Error("err")}); | ||
// logger.log("info", "some message"); | ||
// logger.info("info", {info: "some"}); | ||
// logger.error({info: "some"}, "some"); | ||
// logger.error({info: "some"}, {tokens: "token"}); | ||
// logger.error({info: "some"}, [{tokens: "token"}, [{second: "two"}]]); | ||
}); | ||
}); |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9199
185
0