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

@workpop/simple-logger

Package Overview
Dependencies
Maintainers
9
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.3.2 to 1.3.3

10

CHANGELOG.md

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

<a name="1.3.3"></a>
## [1.3.3](https://github.com/Workpop/simple-logger/compare/v1.3.2...v1.3.3) (2018-07-21)
### Bug Fixes
* **errors:** log error name, message, stack when single argument to any log function (#6) ([dc7b612](https://github.com/Workpop/simple-logger/commit/dc7b612))
<a name="1.3.2"></a>

@@ -7,0 +17,0 @@ ## [1.3.2](https://github.com/Workpop/simple-logger/compare/v1.3.1...v1.3.2) (2018-05-30)

92

lib/index.js

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

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

@@ -20,4 +15,2 @@

var _util = require('util');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -32,12 +25,7 @@

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

@@ -47,37 +35,22 @@ return;

var base = {
_ts: (0, _moment2.default)().format(),
_level: (0, _lodash.toUpper)(level),
_category: this.category,
_requestId: this.requestId
};
var now = (0, _moment2.default)().format();
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];
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
args[_key - 2] = arguments[_key];
}
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: (0, _lodash.map)(args, function (x) {
if ((0, _lodash.isString)(x)) {
return x;
}
return (0, _util.inspect)(x);
}).join(' ')
});
if (level === logLevels.ERROR) {
var _console;
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
return (_console2 = console).log.apply(_console2, [now + ' ' + level + ' [' + category + ']'].concat(args)); // eslint-disable-line no-console
}
if (JSON_MODE) {
return stream(JSON.stringify(ll));
}
function Logger(category, requestId) {
this.category = category;
this.requestId = requestId;
}
return stream.apply(undefined, [ll._ts + ' ' + ll._level + ' [' + ll._category + ']'].concat(args));
};
Logger.disable = function () {

@@ -91,8 +64,35 @@ IS_ENABLED = false;

Logger.prototype.trace = (0, _lodash.partial)(Logger.prototype.log, logLevels.TRACE);
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.info = (0, _lodash.partial)(Logger.prototype.log, logLevels.INFO);
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.warn = (0, _lodash.partial)(Logger.prototype.log, logLevels.WARN);
Logger.prototype.trace = createLogLevel(logLevels.TRACE);
Logger.prototype.error = (0, _lodash.partial)(Logger.prototype.log, logLevels.ERROR);
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));
};
{
"name": "@workpop/simple-logger",
"version": "1.3.2",
"version": "1.3.3",
"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