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

@bitdiver/model

Package Overview
Dependencies
Maintainers
2
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bitdiver/model - npm Package Compare versions

Comparing version 1.3.4 to 1.3.5

tests/StepBaseLogLevelTest.js

58

lib/LogAdapter.js

@@ -26,5 +26,7 @@ 'use strict';

class LogAdapter {
constructor() {
constructor(opts = {}) {
// default is not to write to console
this.writeConsole = false;
this.logAdapterLogLevel = opts.logLevel ? opts.logLevel : LEVEL_DEBUG;
}

@@ -39,2 +41,29 @@

/**
* Gets a numeric loglevel by loglevel symbol
* @param loglevel {string} the loglevel to calc the numeric value for
* @param logLevel {number} the numeric value
*/
_getLogLevel(logLevel) {
if (LEVEL_DEBUG === logLevel) {
return 1;
} else if (LEVEL_INFO === logLevel) {
return 2;
} else if (LEVEL_WARNING === logLevel) {
return 3;
} else if (LEVEL_ERROR === logLevel) {
return 4;
} else if (LEVEL_FATAL === logLevel) {
return 5;
}
}
/**
* Function which determines if a log message should be logged
* @param messageLogLevel {string} the message loglevel
*/
_messageShouldBeLogged(messageLogLevel) {
return this._getLogLevel(messageLogLevel) >= this._getLogLevel(this.logAdapterLogLevel);
}
/**
* @param data {object} The object with the data to be logged and the needed meta data

@@ -74,17 +103,20 @@ * const logMessage = {

// Set the time of the log
meta.logTime = Date.now();
const messageShouldBeLogged = this._messageShouldBeLogged(logLevel, this.logAdapterLogLevel);
if (messageShouldBeLogged) {
// Set the time of the log
meta.logTime = Date.now();
// set the loglevel
meta.logLevel = logMessage.logLevel;
// set the loglevel
meta.logLevel = logMessage.logLevel;
if (meta.step !== undefined && meta.step.id !== undefined) {
// this is a step log
return this._logStep(meta, data, logLevel);
} else if (meta.tc !== undefined && meta.tc.id !== undefined) {
// This is a testcase log
return this._logTestcase(meta, data, logLevel);
if (meta.step !== undefined && meta.step.id !== undefined) {
// this is a step log
return this._logStep(meta, data, logLevel);
} else if (meta.tc !== undefined && meta.tc.id !== undefined) {
// This is a testcase log
return this._logTestcase(meta, data, logLevel);
}
// This is a run log
return this._logRun(meta, data, logLevel);
}
// This is a run log
return this._logRun(meta, data, logLevel);
}

@@ -91,0 +123,0 @@

@@ -51,4 +51,4 @@ 'use strict';

class LogAdapterMemory extends _LogAdapter.LogAdapter {
constructor() {
super();
constructor(opts = {}) {
super(opts);
this.logs = {};

@@ -55,0 +55,0 @@ }

{
"name": "@bitdiver/model",
"version": "1.3.4",
"version": "1.3.5",
"description": "",

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

@@ -8,4 +8,8 @@ import {

const logAdapterMemory = getLogAdapterMemory()
const LOG_ADAPTER_LOG_LEVEL = 'debug'
const logAdapterMemory = getLogAdapterMemory({
logLevel: LOG_ADAPTER_LOG_LEVEL,
})
test('Logging: info', () => {

@@ -12,0 +16,0 @@ const step = getStep()

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