New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

btrz-logger

Package Overview
Dependencies
Maintainers
2
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

btrz-logger - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

10

constants.js

@@ -10,5 +10,13 @@ const CONSOLE_OUTPUT = "CONSOLE_OUTPUT";

SILENT_OUTPUT,
ALL_OUTPUT_DESTINATIONS: [CONSOLE_OUTPUT, LOGENTRIES_OUTPUT, SILENT_OUTPUT]
ALL_OUTPUT_DESTINATIONS: [CONSOLE_OUTPUT, LOGENTRIES_OUTPUT, SILENT_OUTPUT],
LOG_LEVEL_DEBUG: "debug",
LOG_LEVEL_INFO: "info",
LOG_LEVEL_NOTICE: "notice",
LOG_LEVEL_WARNING: "warning",
LOG_LEVEL_ERROR: "err",
LOG_LEVEL_CRITICAL: "crit",
LOG_LEVEL_ALERT: "alert",
LOG_LEVEL_EMERGENCY: "emerg"
};
module.exports = constants;

2

package.json
{
"name": "btrz-logger",
"version": "2.2.0",
"version": "2.3.0",
"description": "A multi-transport logger",

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

@@ -12,3 +12,3 @@ const assert = require("assert");

constructor(options) {
const {serverId, logEntriesToken, outputDestinations} = options;
const {serverId, logEntriesToken, outputDestinations, level} = options;

@@ -18,7 +18,10 @@ this.serverId = serverId;

this.outputDestinations = outputDestinations;
this.level = level;
}
create(options = {}) {
const {outputDestinations, traceId} = options;
const {outputDestinations, traceId, level} = options;
const _outputDestinations = outputDestinations || this.outputDestinations;
const _level = level || this.level;

@@ -29,3 +32,4 @@ assert(Array.isArray(_outputDestinations) && _outputDestinations.length > 0, "an array of one or more outputDestinations is required");

serverId: this.serverId,
traceId
traceId,
level: _level
});

@@ -32,0 +36,0 @@

@@ -6,3 +6,4 @@ const {expect} = require("chai");

const sandbox = sinon.createSandbox();
const {ALL_OUTPUT_DESTINATIONS, CONSOLE_OUTPUT, LOGENTRIES_OUTPUT, SILENT_OUTPUT} = require("../constants");
const {ALL_OUTPUT_DESTINATIONS, CONSOLE_OUTPUT, LOGENTRIES_OUTPUT, SILENT_OUTPUT, LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_NOTICE,
LOG_LEVEL_WARNING, LOG_LEVEL_ERROR, LOG_LEVEL_CRITICAL, LOG_LEVEL_ALERT, LOG_LEVEL_EMERGENCY} = require("../constants");
const {ConsoleLogger} = require("../src/console-logger");

@@ -47,5 +48,8 @@ const {LogEntriesLogger} = require("../src/log-entries-logger");

let loggerFactory = null;
let level = null;
beforeEach(() => {
loggerFactory = new LoggerFactory({serverId, logEntriesToken, outputDestinations});
level = chance.pickone([LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_NOTICE, LOG_LEVEL_WARNING, LOG_LEVEL_ERROR,
LOG_LEVEL_CRITICAL, LOG_LEVEL_ALERT, LOG_LEVEL_EMERGENCY]);
loggerFactory = new LoggerFactory({serverId, logEntriesToken, outputDestinations, level});
});

@@ -113,5 +117,17 @@

const logger = loggerFactory.create({traceId});
expect(logger.options).to.deep.eql({serverId, traceId});
expect(logger.options).to.deep.contain({serverId, traceId});
});
it("should return a Logger instance that has the specified minimum log level", () => {
level = chance.pickone([LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_NOTICE, LOG_LEVEL_WARNING, LOG_LEVEL_ERROR,
LOG_LEVEL_CRITICAL, LOG_LEVEL_ALERT, LOG_LEVEL_EMERGENCY]);
const logger = loggerFactory.create({level});
expect(logger.level).to.eql(level);
});
it("should default to using the log level that was provided to the class constructor", () => {
const logger = loggerFactory.create({});
expect(logger.level).to.eql(level);
});
it("should allow options to be omitted", () => {

@@ -118,0 +134,0 @@ // We just expect this test to to not throw an error

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