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

fm-log

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fm-log - npm Package Compare versions

Comparing version 4.0.3 to 4.1.0

.codeclimate.yml

21

lib/LogFactory.js
// jscs:disable requireNamedUnassignedFunctions
"use strict";
const Logger = require( "./Logger" );
const Logger = require( "./Logger" );
const LogLevels = require( "./LogLevels" );

@@ -14,2 +15,6 @@ class LogFactory {

this.__loggers = [];
this.isSilent = false;
this.minLevel = LogLevels.DEBUG;
}

@@ -43,4 +48,5 @@

instance( prefix, stream ) {
const logger = new Logger( prefix, stream );
const logger = new Logger( prefix, stream );
logger.enableLogging = !this.isSilent;
logger.__minLevel = this.minLevel;
this.__loggers.push( logger );

@@ -51,3 +57,3 @@ return logger;

silence( beSilent ) {
beSilent = beSilent || true;
beSilent = typeof beSilent === "undefined" ? true : false;

@@ -59,4 +65,13 @@ this.isSilent = beSilent;

}
require( level ) {
level = level || LogLevels.DEBUG;
this.minLevel = level;
this.__loggers.forEach( logger => {
logger.__minLevel = level;
} );
}
}
module.exports = new LogFactory();

@@ -84,2 +84,7 @@ // jscs:disable requireNamedUnassignedFunctions

require( level ) {
this.__minLevel = level;
return this;
}
/**

@@ -270,3 +275,3 @@ * Create and wrap a morgan instance.

// Assume either 4 (no function name) or 5 elements.
if( callSiteElements.length == 5 ) {
if( callSiteElements.length === 5 ) {
functionName = callSiteElements[ 1 ];

@@ -273,0 +278,0 @@ fileName = callSiteElements[ 2 ];

6

lib/MessageFormatter.js

@@ -53,3 +53,3 @@ "use strict";

static format( message ) {
message = ( typeof message == "string" || message instanceof String ) ? MessageFormatter.formatString.apply(
message = ( typeof message === "string" || message instanceof String ) ? MessageFormatter.formatString.apply(
this,

@@ -71,3 +71,3 @@ arguments ) : message;

static generateLogStack( level, prefix, subject, colorizer ) {
const subjectString = ( util.isArray( subject ) || typeof subject == "object" ) ? MessageFormatter.stringify( subject ) : subject.toString();
const subjectString = ( util.isArray( subject ) || typeof subject === "object" ) ? MessageFormatter.stringify( subject ) : subject.toString();
const lines = subjectString.split( "\n" );

@@ -78,3 +78,3 @@ let levelString = LogLevels.render( level );

// Most common case, a single line.
if( lines.length == 1 ) {
if( lines.length === 1 ) {
return colorizer( `${levelString} ${MessageFormatter.prefixMessage( prefix, subject )}` );

@@ -81,0 +81,0 @@ }

{
"name": "fm-log",
"version": "4.0.3",
"version": "4.1.0",
"description": "Console logging facility for Node",

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

@@ -5,2 +5,3 @@ "use strict";

const after = mocha.after;
const afterEach = mocha.afterEach;

@@ -244,2 +245,6 @@ const beforeEach = mocha.beforeEach;

describe( "silence", () => {
after( () => {
require( "../lib/log.js" ).logFactory.silence( false );
} );
it( "shouldn't log when silenced", () => {

@@ -258,2 +263,34 @@ log = require( "../lib/log.js" ).module( "" ).to( logStream ).off();

} );
describe( "level requirements", () => {
beforeEach( () => {
log = require( "../lib/log.js" ).module( "" ).to( logStream );
} );
after( () => {
require( "../lib/log.js" ).logFactory.require();
} );
it( "should not log when level is below min", () => {
const LogLevels = require( "../lib/LogLevels" );
log.require( LogLevels.ERROR );
log.debug( "!" );
result.should.have.length( 0 );
} );
it( "should not log when global level is below min", () => {
const LogLevels = require( "../lib/LogLevels" );
require( "../lib/log.js" ).logFactory.require( LogLevels.ERROR );
log.debug( "!" );
result.should.have.length( 0 );
} );
it( "should log when level is at min", () => {
const LogLevels = require( "../lib/LogLevels" );
log.require( LogLevels.INFO );
log.info( "!" );
result.should.have.length( 1 );
result[ 0 ].should.match( /\d \[INFO ] \( foo\) !/ );
} );
} );
} );

@@ -5,4 +5,2 @@ "use strict";

const afterEach = mocha.afterEach;
const beforeEach = mocha.beforeEach;
const chalk = require( "chalk" );

@@ -9,0 +7,0 @@ const describe = mocha.describe;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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