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

@koopjs/logger

Package Overview
Dependencies
Maintainers
7
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@koopjs/logger - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

4

package.json
{
"name": "@koopjs/logger",
"version": "3.0.1",
"version": "4.0.0",
"description": "A shared logger for Koop",

@@ -13,3 +13,3 @@ "main": "src/index.js",

"type": "git",
"url": "https://www.github.com/koopjs/koop-logger.git"
"url": "https://www.github.com/koopjs/koop.git"
},

@@ -16,0 +16,0 @@ "keywords": [

# Koop-Logger
[![Greenkeeper badge](https://badges.greenkeeper.io/koopjs/koop-logger.svg)](https://greenkeeper.io/)
* A shared logger for Koop
[![Build Status](https://travis-ci.org/koopjs/koop-logger.svg?branch=master)](https://travis-ci.org/koopjs/koop-logger)
## Usage

@@ -9,0 +4,0 @@ `npm install @koopjs/logger`

@@ -13,26 +13,34 @@ /* @flow */

config = config || {};
let level;
if (process.env.KOOP_LOG_LEVEL) {
level = process.env.KOOP_LOG_LEVEL;
} else if (process.env.NODE_ENV === 'production') {
level = 'info';
} else {
level = 'debug';
const level = setLogLevel(config.logLevel);
if (config.logfile) {
const fileTransports = setupFileTransport(config.logfile, level);
return winston.createLogger({ transports: fileTransports });
}
if (!config.logfile) {
// no logfile defined, log to STDOUT an STDERRv
const debugConsole = new winston.transports.Console({
colorize: process.env.NODE_ENV === 'production',
level,
stringify: true,
json: true
});
return winston.createLogger({ transports: [debugConsole] });
const consoleTransport = new winston.transports.Console({
colorize: true,
level,
stringify: true,
json: true
});
return winston.createLogger({ transports: [consoleTransport] });
}
function setLogLevel (logLevel) {
if (logLevel) {
return logLevel;
}
// we need a dir to do log rotation so we get the dir from the file
const logpath = path.dirname(config.logfile);
if (process.env.KOOP_LOG_LEVEL || process.env.LOG_LEVEL) {
return process.env.KOOP_LOG_LEVEL || process.env.LOG_LEVEL;
}
return 'info';
}
function setupFileTransport (logfile, level) {
const logpath = path.dirname(logfile);
const logAll = new winston.transports.File({
filename: config.logfile,
filename: logfile,
name: 'log.all',

@@ -45,4 +53,5 @@ dirname: logpath,

});
const logError = new winston.transports.File({
filename: config.logfile.replace('.log', '.error.log'),
filename: logfile.replace('.log', '.error.log'),
name: 'log.error',

@@ -56,10 +65,9 @@ dirname: logpath,

// always log errors
const transports = [logError];
// only log everthing if debug mode is on
if (process.env.LOG_LEVEL === 'debug') {
if (level === 'debug') {
transports.push(logAll);
}
return winston.createLogger({ transports });
return transports;
}

@@ -66,0 +74,0 @@

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