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

@workpop/simple-logger

Package Overview
Dependencies
Maintainers
17
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@workpop/simple-logger - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

.npmignore

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="1.3.0"></a>
# [1.3.0](https://github.com/Workpop/simple-logger/compare/v1.2.0...v1.3.0) (2018-05-30)
### Features
* **json:** log as json in NODE_ENV production ([3da67cb](https://github.com/Workpop/simple-logger/commit/3da67cb))
<a name="1.2.0"></a>

@@ -7,0 +17,0 @@ # [1.2.0](https://github.com/Workpop/simple-logger/compare/v1.1.0...v1.2.0) (2018-02-09)

84

lib/index.js

@@ -6,2 +6,7 @@ 'use strict';

});
var _extends2 = require('babel-runtime/helpers/extends');
var _extends3 = _interopRequireDefault(_extends2);
exports.default = Logger;

@@ -23,8 +28,12 @@

};
var JSON_MODE = process.env.NODE_ENV === 'production';
var IS_ENABLED = true;
function _log(category, level) {
var _console2;
function Logger(category, requestId) {
this.category = category;
this.requestId = requestId;
}
Logger.prototype.log = function log(level) {
if (!IS_ENABLED) {

@@ -34,22 +43,32 @@ return;

var now = (0, _moment2.default)().format();
var base = {
_ts: (0, _moment2.default)().format(),
_level: (0, _lodash.toUpper)(level),
_category: this.category,
_requestId: this.requestId
};
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
var ll = void 0;
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
if (level === logLevels.ERROR) {
var _console;
if ((0, _lodash.size)(args) === 1 && (0, _lodash.isObject)(args[0])) {
ll = (0, _extends3.default)({}, base, args[0]);
} else {
ll = (0, _extends3.default)({}, base, {
message: args.join(' ')
});
}
return (_console = console).error.apply(_console, [now + ' ' + level + ' [' + category + ']'].concat(args)); // eslint-disable-line no-console
var stream = level === logLevels.ERROR ? console.error : console.log; //eslint-disable-line no-console
if (JSON_MODE) {
return stream(JSON.stringify(ll));
}
return (_console2 = console).log.apply(_console2, [now + ' ' + level + ' [' + category + ']'].concat(args)); // eslint-disable-line no-console
}
return stream.apply(undefined, [ll._ts + ' ' + ll._level + ' [' + ll._category + ']'].concat(args));
};
function Logger(category, requestId) {
this.category = category;
this.requestId = requestId;
}
Logger.disable = function () {

@@ -63,35 +82,8 @@ IS_ENABLED = false;

function createLogLevel(level) {
return function logWithLevel() {
for (var _len2 = arguments.length, args = Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
Logger.prototype.trace = (0, _lodash.partial)(Logger.prototype.log, logLevels.TRACE);
if (this.requestId) {
_log.apply(undefined, [this.category, level, 'RequestId: ' + this.requestId].concat(args));
return;
}
_log.apply(undefined, [this.category, level].concat(args));
};
}
Logger.prototype.info = (0, _lodash.partial)(Logger.prototype.log, logLevels.INFO);
Logger.prototype.trace = createLogLevel(logLevels.TRACE);
Logger.prototype.warn = (0, _lodash.partial)(Logger.prototype.log, logLevels.WARN);
Logger.prototype.info = createLogLevel(logLevels.INFO);
Logger.prototype.warn = createLogLevel(logLevels.WARN);
Logger.prototype.error = createLogLevel(logLevels.ERROR);
Logger.prototype.log = function log(level) {
for (var _len3 = arguments.length, args = Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
args[_key3 - 1] = arguments[_key3];
}
if ((0, _lodash.size)(args) === 1 && (0, _lodash.isObject)(args[0])) {
_log(this.category, (0, _lodash.toUpper)(level), JSON.stringify(args[0]));
return;
}
_log.apply(undefined, [this.category, (0, _lodash.toUpper)(level)].concat(args));
};
Logger.prototype.error = (0, _lodash.partial)(Logger.prototype.log, logLevels.ERROR);
{
"name": "@workpop/simple-logger",
"version": "1.2.0",
"version": "1.3.0",
"description": "Simple console logger",

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

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