Comparing version 2.5.1 to 2.6.0
@@ -11,2 +11,5 @@ # CHANGELOG | ||
**2023/02/06** | ||
## Most Important: | ||
* Now incompatible with TypeScript < 4.4 due to [PR #240](https://github.com/winstonjs/logform/pull/240), as pointed out in [#244](https://github.com/winstonjs/logform/issues/244). | ||
## Improvements | ||
@@ -13,0 +16,0 @@ All the improvements in this release are from first-time contributors - thanks for your contributions! |
'use strict'; | ||
var format = require('./format'); | ||
/* | ||
@@ -10,4 +11,2 @@ * function align (info) | ||
*/ | ||
module.exports = format(function (info) { | ||
@@ -14,0 +13,0 @@ info.message = "\t".concat(info.message); |
'use strict'; | ||
/* | ||
@@ -8,4 +9,4 @@ * @api public | ||
*/ | ||
var format = exports.format = require('././format'); | ||
var format = exports.format = require('././format'); | ||
/* | ||
@@ -16,9 +17,8 @@ * @api public | ||
*/ | ||
exports.levels = require('././levels'); | ||
exports.levels = require('././levels'); // | ||
// | ||
// Setup all transports as eager-loaded exports | ||
// so that they are static for the bundlers. | ||
// | ||
Object.defineProperty(format, 'align', { | ||
@@ -25,0 +25,0 @@ value: require('./align') |
'use strict'; | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var _require = require('./colorize'), | ||
Colorizer = _require.Colorizer; | ||
Colorizer = _require.Colorizer; | ||
var _require2 = require('./pad-levels'), | ||
Padder = _require2.Padder; | ||
Padder = _require2.Padder; | ||
var _require3 = require('triple-beam'), | ||
configs = _require3.configs, | ||
MESSAGE = _require3.MESSAGE; | ||
var _require3 = require('triple-beam'), | ||
configs = _require3.configs, | ||
MESSAGE = _require3.MESSAGE; | ||
/** | ||
@@ -22,14 +21,9 @@ * Cli format class that handles initial state for a a separate | ||
*/ | ||
var CliFormat = /*#__PURE__*/function () { | ||
function CliFormat() { | ||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_classCallCheck(this, CliFormat); | ||
if (!opts.levels) { | ||
opts.levels = configs.cli.levels; | ||
} | ||
this.colorizer = new Colorizer(opts); | ||
@@ -39,2 +33,3 @@ this.padder = new Padder(opts); | ||
} | ||
/* | ||
@@ -47,4 +42,2 @@ * function transform (info, opts) | ||
*/ | ||
_createClass(CliFormat, [{ | ||
@@ -58,3 +51,2 @@ key: "transform", | ||
}]); | ||
return CliFormat; | ||
@@ -68,11 +60,9 @@ }(); | ||
*/ | ||
module.exports = function (opts) { | ||
return new CliFormat(opts); | ||
}; // | ||
}; | ||
// | ||
// Attach the CliFormat for registration purposes | ||
// | ||
module.exports.Format = CliFormat; |
'use strict'; | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var colors = require('@colors/colors/safe'); | ||
var _require = require('triple-beam'), | ||
LEVEL = _require.LEVEL, | ||
MESSAGE = _require.MESSAGE; | ||
var _require = require('triple-beam'), | ||
LEVEL = _require.LEVEL, | ||
MESSAGE = _require.MESSAGE; // | ||
// | ||
// Fix colors not appearing in non-tty environments | ||
// | ||
colors.enabled = true; | ||
colors.enabled = true; | ||
/** | ||
@@ -23,4 +23,4 @@ * @property {RegExp} hasSpace | ||
*/ | ||
var hasSpace = /\s+/; | ||
var hasSpace = /\s+/; | ||
/* | ||
@@ -30,15 +30,12 @@ * Colorizer format. Wraps the `level` and/or `message` properties | ||
*/ | ||
var Colorizer = /*#__PURE__*/function () { | ||
function Colorizer() { | ||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
_classCallCheck(this, Colorizer); | ||
if (opts.colors) { | ||
this.addColors(opts.colors); | ||
} | ||
this.options = opts; | ||
} | ||
/* | ||
@@ -50,4 +47,2 @@ * Adds the colors Object to the set of allColors | ||
*/ | ||
_createClass(Colorizer, [{ | ||
@@ -65,2 +60,3 @@ key: "addColors", | ||
} | ||
/* | ||
@@ -70,3 +66,2 @@ * function colorize (lookup, level, message) | ||
*/ | ||
}, { | ||
@@ -77,22 +72,22 @@ key: "colorize", | ||
message = level; | ||
} // | ||
} | ||
// | ||
// If the color for the level is just a string | ||
// then attempt to colorize the message with it. | ||
// | ||
if (!Array.isArray(Colorizer.allColors[lookup])) { | ||
return colors[Colorizer.allColors[lookup]](message); | ||
} // | ||
} | ||
// | ||
// If it is an Array then iterate over that Array, applying | ||
// the colors function for each item. | ||
// | ||
for (var i = 0, len = Colorizer.allColors[lookup].length; i < len; i++) { | ||
message = colors[Colorizer.allColors[lookup][i]](message); | ||
} | ||
return message; | ||
} | ||
/* | ||
@@ -103,3 +98,2 @@ * function transform (info, opts) | ||
*/ | ||
}, { | ||
@@ -111,11 +105,8 @@ key: "transform", | ||
} | ||
if (opts.level || opts.all || !opts.message) { | ||
info.level = this.colorize(info[LEVEL], info.level); | ||
} | ||
if (opts.all || opts.message) { | ||
info.message = this.colorize(info[LEVEL], info.level, info.message); | ||
} | ||
return info; | ||
@@ -134,3 +125,2 @@ } | ||
}]); | ||
return Colorizer; | ||
@@ -144,11 +134,9 @@ }(); | ||
*/ | ||
module.exports = function (opts) { | ||
return new Colorizer(opts); | ||
}; // | ||
}; | ||
// | ||
// Attach the Colorizer for registration purposes | ||
// | ||
module.exports.Colorizer = module.exports.Format = Colorizer; |
'use strict'; | ||
var format = require('./format'); | ||
/* | ||
@@ -11,4 +12,2 @@ * function cascade(formats) | ||
*/ | ||
function cascade(formats) { | ||
@@ -18,9 +17,6 @@ if (!formats.every(isValidFormat)) { | ||
} | ||
return function (info) { | ||
var obj = info; | ||
for (var i = 0; i < formats.length; i++) { | ||
obj = formats[i].transform(obj, formats[i].options); | ||
if (!obj) { | ||
@@ -30,6 +26,6 @@ return false; | ||
} | ||
return obj; | ||
}; | ||
} | ||
/* | ||
@@ -40,4 +36,2 @@ * function isValidFormat(format) | ||
*/ | ||
function isValidFormat(fmt) { | ||
@@ -47,5 +41,5 @@ if (typeof fmt.transform !== 'function') { | ||
} | ||
return true; | ||
} | ||
/* | ||
@@ -58,4 +52,2 @@ * function combine (info) | ||
*/ | ||
module.exports = function () { | ||
@@ -65,3 +57,2 @@ for (var _len = arguments.length, formats = new Array(_len), _key = 0; _key < _len; _key++) { | ||
} | ||
var combinedFormat = format(cascade(formats)); | ||
@@ -71,3 +62,5 @@ var instance = combinedFormat(); | ||
return instance; | ||
}; // | ||
}; | ||
// | ||
// Export the cascade method for use in cli and other | ||
@@ -77,4 +70,2 @@ // combined formats that should not be assumed to be | ||
// | ||
module.exports.cascade = cascade; |
/* eslint no-undefined: 0 */ | ||
'use strict'; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var format = require('./format'); | ||
var _require = require('triple-beam'), | ||
LEVEL = _require.LEVEL, | ||
MESSAGE = _require.MESSAGE; | ||
var _require = require('triple-beam'), | ||
LEVEL = _require.LEVEL, | ||
MESSAGE = _require.MESSAGE; | ||
/* | ||
@@ -18,11 +20,7 @@ * function errors (info) | ||
*/ | ||
module.exports = format(function (einfo, _ref) { | ||
var stack = _ref.stack, | ||
cause = _ref.cause; | ||
cause = _ref.cause; | ||
if (einfo instanceof Error) { | ||
var _Object$assign; | ||
var info = Object.assign({}, einfo, (_Object$assign = { | ||
@@ -35,11 +33,12 @@ level: einfo.level | ||
} | ||
if (!(einfo.message instanceof Error)) return einfo; | ||
if (!(einfo.message instanceof Error)) return einfo; // Assign all enumerable properties and the | ||
// Assign all enumerable properties and the | ||
// message property from the error provided. | ||
var err = einfo.message; | ||
Object.assign(einfo, err); | ||
einfo.message = err.message; | ||
einfo[MESSAGE] = err.message; // Assign the stack and/or cause if requested. | ||
einfo[MESSAGE] = err.message; | ||
// Assign the stack and/or cause if requested. | ||
if (stack) einfo.stack = err.stack; | ||
@@ -46,0 +45,0 @@ if (cause) einfo.cause = err.cause; |
'use strict'; | ||
/* | ||
@@ -6,41 +7,24 @@ * Displays a helpful message and the source of | ||
*/ | ||
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } | ||
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } | ||
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } | ||
function _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf("[native code]") !== -1; } catch (e) { return typeof fn === "function"; } } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
var InvalidFormatError = /*#__PURE__*/function (_Error) { | ||
_inherits(InvalidFormatError, _Error); | ||
var _super = _createSuper(InvalidFormatError); | ||
function InvalidFormatError(formatFn) { | ||
var _this; | ||
_classCallCheck(this, InvalidFormatError); | ||
_this = _super.call(this, "Format functions must be synchronous taking a two arguments: (info, opts)\nFound: ".concat(formatFn.toString().split('\n')[0], "\n")); | ||
@@ -50,3 +34,2 @@ Error.captureStackTrace(_assertThisInitialized(_this), InvalidFormatError); | ||
} | ||
return _createClass(InvalidFormatError); | ||
@@ -58,4 +41,2 @@ }( /*#__PURE__*/_wrapNativeSuper(Error)); | ||
*/ | ||
module.exports = function (formatFn) { | ||
@@ -65,2 +46,3 @@ if (formatFn.length > 2) { | ||
} | ||
/* | ||
@@ -71,4 +53,2 @@ * function Format (options) | ||
*/ | ||
function Format() { | ||
@@ -78,4 +58,5 @@ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
} | ||
Format.prototype.transform = formatFn; | ||
Format.prototype.transform = formatFn; // | ||
// | ||
// Create a function which returns new instances of | ||
@@ -86,13 +67,12 @@ // FormatWrap for simple syntax like: | ||
// | ||
function createFormatWrap(opts) { | ||
return new Format(opts); | ||
} // | ||
} | ||
// | ||
// Expose the FormatWrap through the create function | ||
// for testability. | ||
// | ||
createFormatWrap.Format = Format; | ||
return createFormatWrap; | ||
}; |
'use strict'; | ||
/* | ||
@@ -8,4 +9,4 @@ * @api public | ||
*/ | ||
var format = exports.format = require('./format'); | ||
var format = exports.format = require('./format'); | ||
/* | ||
@@ -16,5 +17,4 @@ * @api public | ||
*/ | ||
exports.levels = require('./levels'); | ||
exports.levels = require('./levels'); | ||
/* | ||
@@ -26,3 +26,2 @@ * @api private | ||
*/ | ||
function exposeFormat(name, requireFormat) { | ||
@@ -35,7 +34,7 @@ Object.defineProperty(format, name, { | ||
}); | ||
} // | ||
} | ||
// | ||
// Setup all transports as lazy-loaded getters. | ||
// | ||
exposeFormat('align', function () { | ||
@@ -42,0 +41,0 @@ return require('./align'); |
'use strict'; | ||
var format = require('./format'); | ||
var _require = require('triple-beam'), | ||
MESSAGE = _require.MESSAGE; | ||
MESSAGE = _require.MESSAGE; | ||
var stringify = require('safe-stable-stringify'); | ||
var stringify = require('safe-stable-stringify'); | ||
/* | ||
@@ -13,4 +12,2 @@ * function replacer (key, value) | ||
*/ | ||
function replacer(key, value) { | ||
@@ -23,2 +20,3 @@ // safe-stable-stringify does support BigInt, however, it doesn't wrap the value in quotes. | ||
} | ||
/* | ||
@@ -30,4 +28,2 @@ * function json (info) | ||
*/ | ||
module.exports = format(function (info, opts) { | ||
@@ -34,0 +30,0 @@ var jsonStringify = stringify.configure(opts); |
'use strict'; | ||
var format = require('./format'); | ||
/* | ||
@@ -10,4 +11,2 @@ * function label (info) | ||
*/ | ||
module.exports = format(function (info, opts) { | ||
@@ -18,5 +17,4 @@ if (opts.message) { | ||
} | ||
info.label = opts.label; | ||
return info; | ||
}); |
'use strict'; | ||
var _require = require('./colorize'), | ||
Colorizer = _require.Colorizer; | ||
Colorizer = _require.Colorizer; | ||
/* | ||
@@ -9,4 +10,2 @@ * Simple method to register colors with a simpler require | ||
*/ | ||
module.exports = function (config) { | ||
@@ -13,0 +12,0 @@ Colorizer.addColors(config.colors || config); |
'use strict'; | ||
var format = require('./format'); | ||
var _require = require('triple-beam'), | ||
MESSAGE = _require.MESSAGE; | ||
MESSAGE = _require.MESSAGE; | ||
var jsonStringify = require('safe-stable-stringify'); | ||
var jsonStringify = require('safe-stable-stringify'); | ||
/* | ||
@@ -16,7 +15,4 @@ * function logstash (info) | ||
*/ | ||
module.exports = format(function (info) { | ||
var logstash = {}; | ||
if (info.message) { | ||
@@ -26,3 +22,2 @@ logstash['@message'] = info.message; | ||
} | ||
if (info.timestamp) { | ||
@@ -32,3 +27,2 @@ logstash['@timestamp'] = info.timestamp; | ||
} | ||
logstash['@fields'] = info; | ||
@@ -35,0 +29,0 @@ info[MESSAGE] = jsonStringify(logstash); |
'use strict'; | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var format = require('./format'); | ||
function fillExcept(info, fillExceptKeys, metadataKey) { | ||
@@ -21,3 +22,2 @@ var savedKeys = fillExceptKeys.reduce(function (acc, key) { | ||
} | ||
function fillWith(info, fillWithKeys, metadataKey) { | ||
@@ -31,2 +31,3 @@ info[metadataKey] = fillWithKeys.reduce(function (acc, key) { | ||
} | ||
/** | ||
@@ -36,14 +37,9 @@ * Adds in a "metadata" object to collect extraneous data, similar to the metadata | ||
*/ | ||
module.exports = format(function (info) { | ||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var metadataKey = 'metadata'; | ||
if (opts.key) { | ||
metadataKey = opts.key; | ||
} | ||
var fillExceptKeys = []; | ||
if (!opts.fillExcept && !opts.fillWith) { | ||
@@ -53,16 +49,12 @@ fillExceptKeys.push('level'); | ||
} | ||
if (opts.fillExcept) { | ||
fillExceptKeys = opts.fillExcept; | ||
} | ||
if (fillExceptKeys.length > 0) { | ||
return fillExcept(info, fillExceptKeys, metadataKey); | ||
} | ||
if (opts.fillWith) { | ||
return fillWith(info, opts.fillWith, metadataKey); | ||
} | ||
return info; | ||
}); |
'use strict'; | ||
var _this = void 0; | ||
var format = require('./format'); | ||
var ms = require('ms'); | ||
var ms = require('ms'); | ||
/* | ||
@@ -13,4 +12,2 @@ * function ms (info) | ||
*/ | ||
module.exports = format(function (info) { | ||
@@ -17,0 +14,0 @@ var curr = +new Date(); |
/* eslint no-unused-vars: 0 */ | ||
'use strict'; | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var _require = require('triple-beam'), | ||
configs = _require.configs, | ||
LEVEL = _require.LEVEL, | ||
MESSAGE = _require.MESSAGE; | ||
configs = _require.configs, | ||
LEVEL = _require.LEVEL, | ||
MESSAGE = _require.MESSAGE; | ||
var Padder = /*#__PURE__*/function () { | ||
@@ -32,8 +25,7 @@ function Padder() { | ||
}; | ||
_classCallCheck(this, Padder); | ||
this.paddings = Padder.paddingForLevels(opts.levels, opts.filler); | ||
this.options = opts; | ||
} | ||
/** | ||
@@ -44,4 +36,2 @@ * Returns the maximum length of keys in the specified `levels` Object. | ||
*/ | ||
_createClass(Padder, [{ | ||
@@ -63,7 +53,5 @@ key: "transform", | ||
info.message = "".concat(this.paddings[info[LEVEL]]).concat(info.message); | ||
if (info[MESSAGE]) { | ||
info[MESSAGE] = "".concat(this.paddings[info[LEVEL]]).concat(info[MESSAGE]); | ||
} | ||
return info; | ||
@@ -79,2 +67,3 @@ } | ||
} | ||
/** | ||
@@ -88,3 +77,2 @@ * Returns the padding for the specified `level` assuming that the | ||
*/ | ||
}, { | ||
@@ -98,2 +86,3 @@ key: "paddingForLevel", | ||
} | ||
/** | ||
@@ -106,3 +95,2 @@ * Returns an object with the string paddings for the given `levels` | ||
*/ | ||
}, { | ||
@@ -119,3 +107,2 @@ key: "paddingForLevels", | ||
}]); | ||
return Padder; | ||
@@ -129,8 +116,5 @@ }(); | ||
*/ | ||
module.exports = function (opts) { | ||
return new Padder(opts); | ||
}; | ||
module.exports.Padder = module.exports.Format = Padder; |
'use strict'; | ||
var inspect = require('util').inspect; | ||
var format = require('./format'); | ||
var _require = require('triple-beam'), | ||
LEVEL = _require.LEVEL, | ||
MESSAGE = _require.MESSAGE, | ||
SPLAT = _require.SPLAT; | ||
var _require = require('triple-beam'), | ||
LEVEL = _require.LEVEL, | ||
MESSAGE = _require.MESSAGE, | ||
SPLAT = _require.SPLAT; | ||
/* | ||
@@ -17,4 +16,2 @@ * function prettyPrint (info) | ||
*/ | ||
module.exports = format(function (info) { | ||
@@ -27,5 +24,6 @@ var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
// | ||
var stripped = Object.assign({}, info); // Remark (indexzero): update this technique in April 2019 | ||
var stripped = Object.assign({}, info); | ||
// Remark (indexzero): update this technique in April 2019 | ||
// when node@6 is EOL | ||
delete stripped[LEVEL]; | ||
@@ -32,0 +30,0 @@ delete stripped[MESSAGE]; |
'use strict'; | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var _require = require('triple-beam'), | ||
MESSAGE = _require.MESSAGE; | ||
MESSAGE = _require.MESSAGE; | ||
var Printf = /*#__PURE__*/function () { | ||
function Printf(templateFn) { | ||
_classCallCheck(this, Printf); | ||
this.template = templateFn; | ||
} | ||
_createClass(Printf, [{ | ||
@@ -26,3 +23,2 @@ key: "transform", | ||
}]); | ||
return Printf; | ||
@@ -36,8 +32,5 @@ }(); | ||
*/ | ||
module.exports = function (opts) { | ||
return new Printf(opts); | ||
}; | ||
module.exports.Printf = module.exports.Format = Printf; |
@@ -5,7 +5,6 @@ /* eslint no-undefined: 0 */ | ||
var format = require('./format'); | ||
var _require = require('triple-beam'), | ||
MESSAGE = _require.MESSAGE; | ||
MESSAGE = _require.MESSAGE; | ||
var jsonStringify = require('safe-stable-stringify'); | ||
var jsonStringify = require('safe-stable-stringify'); | ||
/* | ||
@@ -21,4 +20,2 @@ * function simple (info) | ||
*/ | ||
module.exports = format(function (info) { | ||
@@ -31,3 +28,2 @@ var stringifiedRest = jsonStringify(Object.assign({}, info, { | ||
var padding = info.padding && info.padding[info.level] || ''; | ||
if (stringifiedRest !== '{}') { | ||
@@ -38,4 +34,3 @@ info[MESSAGE] = "".concat(info.level, ":").concat(padding, " ").concat(info.message, " ").concat(stringifiedRest); | ||
} | ||
return info; | ||
}); |
'use strict'; | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } | ||
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } | ||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
var util = require('util'); | ||
var _require = require('triple-beam'), | ||
SPLAT = _require.SPLAT; | ||
var _require = require('triple-beam'), | ||
SPLAT = _require.SPLAT; | ||
/** | ||
@@ -31,5 +25,4 @@ * Captures the number of format (i.e. %s strings) in a given string. | ||
*/ | ||
var formatRegExp = /%[scdjifoO%]/g; | ||
var formatRegExp = /%[scdjifoO%]/g; | ||
/** | ||
@@ -39,11 +32,9 @@ * Captures the number of escaped % signs in a format string (i.e. %s strings). | ||
*/ | ||
var escapedPercent = /%%/g; | ||
var Splatter = /*#__PURE__*/function () { | ||
function Splatter(opts) { | ||
_classCallCheck(this, Splatter); | ||
this.options = opts; | ||
} | ||
/** | ||
@@ -58,4 +49,2 @@ * Check to see if tokens <= splat.length, assign { splat, meta } into the | ||
*/ | ||
_createClass(Splatter, [{ | ||
@@ -67,3 +56,5 @@ key: "_splat", | ||
var percents = msg.match(escapedPercent); | ||
var escapes = percents && percents.length || 0; // The expected splat is the number of tokens minus the number of escapes | ||
var escapes = percents && percents.length || 0; | ||
// The expected splat is the number of tokens minus the number of escapes | ||
// e.g. | ||
@@ -82,12 +73,11 @@ // - { expectedSplat: 3 } '%d %s %j' | ||
// splat = [100, 'wow', { such: 'js' }] | ||
var expectedSplat = tokens.length - escapes; | ||
var extraSplat = expectedSplat - splat.length; | ||
var metas = extraSplat < 0 ? splat.splice(extraSplat, -1 * extraSplat) : []; // Now that { splat } has been separated from any potential { meta }. we | ||
var metas = extraSplat < 0 ? splat.splice(extraSplat, -1 * extraSplat) : []; | ||
// Now that { splat } has been separated from any potential { meta }. we | ||
// can assign this to the `info` object and write it to our format stream. | ||
// If the additional metas are **NOT** objects or **LACK** enumerable properties | ||
// you are going to have a bad time. | ||
var metalen = metas.length; | ||
if (metalen) { | ||
@@ -98,6 +88,6 @@ for (var i = 0; i < metalen; i++) { | ||
} | ||
info.message = util.format.apply(util, [msg].concat(_toConsumableArray(splat))); | ||
return info; | ||
} | ||
/** | ||
@@ -112,3 +102,2 @@ * Transforms the `info` message by using `util.format` to complete | ||
*/ | ||
}, { | ||
@@ -118,21 +107,23 @@ key: "transform", | ||
var msg = info.message; | ||
var splat = info[SPLAT] || info.splat; // No need to process anything if splat is undefined | ||
var splat = info[SPLAT] || info.splat; | ||
// No need to process anything if splat is undefined | ||
if (!splat || !splat.length) { | ||
return info; | ||
} // Extract tokens, if none available default to empty array to | ||
} | ||
// Extract tokens, if none available default to empty array to | ||
// ensure consistancy in expected results | ||
var tokens = msg && msg.match && msg.match(formatRegExp); | ||
var tokens = msg && msg.match && msg.match(formatRegExp); // This condition will take care of inputs with info[SPLAT] | ||
// This condition will take care of inputs with info[SPLAT] | ||
// but no tokens present | ||
if (!tokens && (splat || splat.length)) { | ||
var metas = splat.length > 1 ? splat.splice(0) : splat; | ||
if (!tokens && (splat || splat.length)) { | ||
var metas = splat.length > 1 ? splat.splice(0) : splat; // Now that { splat } has been separated from any potential { meta }. we | ||
// Now that { splat } has been separated from any potential { meta }. we | ||
// can assign this to the `info` object and write it to our format stream. | ||
// If the additional metas are **NOT** objects or **LACK** enumerable properties | ||
// you are going to have a bad time. | ||
var metalen = metas.length; | ||
if (metalen) { | ||
@@ -143,14 +134,10 @@ for (var i = 0; i < metalen; i++) { | ||
} | ||
return info; | ||
} | ||
if (tokens) { | ||
return this._splat(info, tokens); | ||
} | ||
return info; | ||
} | ||
}]); | ||
return Splatter; | ||
@@ -164,6 +151,4 @@ }(); | ||
*/ | ||
module.exports = function (opts) { | ||
return new Splatter(opts); | ||
}; |
'use strict'; | ||
var fecha = require('fecha'); | ||
var format = require('./format'); | ||
var format = require('./format'); | ||
/* | ||
@@ -14,20 +14,14 @@ * function timestamp (info) | ||
*/ | ||
module.exports = format(function (info) { | ||
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
if (opts.format) { | ||
info.timestamp = typeof opts.format === 'function' ? opts.format() : fecha.format(new Date(), opts.format); | ||
} | ||
if (!info.timestamp) { | ||
info.timestamp = new Date().toISOString(); | ||
} | ||
if (opts.alias) { | ||
info[opts.alias] = info.timestamp; | ||
} | ||
return info; | ||
}); |
'use strict'; | ||
var colors = require('@colors/colors/safe'); | ||
var format = require('./format'); | ||
var _require = require('triple-beam'), | ||
MESSAGE = _require.MESSAGE; | ||
var _require = require('triple-beam'), | ||
MESSAGE = _require.MESSAGE; | ||
/* | ||
@@ -15,4 +14,2 @@ * function uncolorize (info) | ||
*/ | ||
module.exports = format(function (info, opts) { | ||
@@ -22,12 +19,9 @@ if (opts.level !== false) { | ||
} | ||
if (opts.message !== false) { | ||
info.message = colors.strip(String(info.message)); | ||
} | ||
if (opts.raw !== false && info[MESSAGE]) { | ||
info[MESSAGE] = colors.strip(String(info[MESSAGE])); | ||
} | ||
return info; | ||
}); |
{ | ||
"name": "logform", | ||
"version": "2.5.1", | ||
"version": "2.6.0", | ||
"description": "An mutable object-based log format designed for chaining & objectMode streams.", | ||
@@ -31,3 +31,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"@colors/colors": "1.5.0", | ||
"@colors/colors": "1.6.0", | ||
"@types/triple-beam": "^1.3.2", | ||
@@ -48,5 +48,8 @@ "fecha": "^4.2.0", | ||
"nyc": "^15.1.0", | ||
"rimraf": "^3.0.2" | ||
"rimraf": "^5.0.5" | ||
}, | ||
"types": "./index.d.ts" | ||
"types": "./index.d.ts", | ||
"engines": { | ||
"node": ">= 12.0.0" | ||
} | ||
} |
@@ -0,0 +0,0 @@ # logform |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
119269
2251
+ Added@colors/colors@1.6.0(transitive)
- Removed@colors/colors@1.5.0(transitive)
Updated@colors/colors@1.6.0