@lskjs/log
Advanced tools
Comparing version 2.64.0 to 2.64.1
{ | ||
"name": "@lskjs/log", | ||
"version": "2.64.0", | ||
"version": "2.64.1", | ||
"description": "Логгер совмещающий лучшие черты debug, bunyan, logfmt/logrus, morgan/winston, ", | ||
@@ -55,3 +55,3 @@ "keywords": [], | ||
}, | ||
"gitHead": "25b4f6761e4b97c0699c3df708de05559dd0d8a9" | ||
"gitHead": "d9c716c50c2bc5c2798df875fdbfe8b86cf6d27e" | ||
} |
@@ -26,3 +26,3 @@ "use strict"; | ||
if (!json) { | ||
if (!json && !!raw.trim()) { | ||
json = (0, _tryLogfmtParse.tryLogfmtParse)(raw); | ||
@@ -44,3 +44,3 @@ } | ||
_parse$args = _parse.args, | ||
args = _parse$args === void 0 ? [] : _parse$args; // console.log({ json, meta, args }); | ||
args = _parse$args === void 0 ? [] : _parse$args; // console.log({ json, format, meta, args }); | ||
// const args = []; | ||
@@ -47,0 +47,0 @@ // if (meta.msg !== null) args.push(meta.msg); |
@@ -41,5 +41,13 @@ export declare type LoggerLevelType = 'fatal' | 'error' | 'warn' | 'debug' | 'info' | 'trace' | 'log'; | ||
}; | ||
export declare enum ILoggerInternalMessageFormat { | ||
bunyan = "bunyan", | ||
lsklog = "lsklog", | ||
lsklogweb = "lsklogweb", | ||
logrus = "logrus", | ||
raw = "raw" | ||
} | ||
export declare type ILoggerInternalMessage = { | ||
format: ILoggerInternalMessageFormat | null; | ||
meta: ILoggerMeta; | ||
args: any[]; | ||
}; |
16
types.js
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.ILoggerInternalMessageFormat = void 0; | ||
// eslint-disable-next-line no-shadow | ||
var ILoggerInternalMessageFormat; | ||
exports.ILoggerInternalMessageFormat = ILoggerInternalMessageFormat; | ||
(function (ILoggerInternalMessageFormat) { | ||
ILoggerInternalMessageFormat["bunyan"] = "bunyan"; | ||
ILoggerInternalMessageFormat["lsklog"] = "lsklog"; | ||
ILoggerInternalMessageFormat["lsklogweb"] = "lsklogweb"; | ||
ILoggerInternalMessageFormat["logrus"] = "logrus"; | ||
ILoggerInternalMessageFormat["raw"] = "raw"; | ||
})(ILoggerInternalMessageFormat || (exports.ILoggerInternalMessageFormat = ILoggerInternalMessageFormat = {})); | ||
//# sourceMappingURL=types.js.map |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _ = require("../.."); | ||
var _toString = require("../toString"); | ||
@@ -50,2 +52,3 @@ | ||
return { | ||
format: _.ILoggerInternalMessageFormat.bunyan, | ||
meta: { | ||
@@ -52,0 +55,0 @@ level: levelMap[level], |
@@ -1,4 +0,4 @@ | ||
import { ILoggerInternalMessage } from '../../types'; | ||
export declare function detectFormat(json: any): string | null; | ||
import { ILoggerInternalMessage, ILoggerInternalMessageFormat } from '../../types'; | ||
export declare function detectFormat(json: any): ILoggerInternalMessageFormat | null; | ||
export declare function stringify(format: string, meta: Record<string, unknown>, ...args: any[]): any; | ||
export declare function parse(json: any): ILoggerInternalMessage; |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _types = require("../../types"); | ||
var _createMsg = require("../createMsg"); | ||
@@ -28,6 +30,6 @@ | ||
function detectFormat(json) { | ||
if ((0, _bunyan.isBunyan)(json)) return 'bunyan'; | ||
if ((0, _lsklog.isLsklog)(json)) return 'lsklog'; | ||
if ((0, _lsklog.isLsklogWeb)(json)) return 'lsklogweb'; | ||
if ((0, _logrus.isLogrus)(json)) return 'logrus'; | ||
if ((0, _bunyan.isBunyan)(json)) return _types.ILoggerInternalMessageFormat.bunyan; | ||
if ((0, _lsklog.isLsklog)(json)) return _types.ILoggerInternalMessageFormat.lsklog; | ||
if ((0, _lsklog.isLsklogWeb)(json)) return _types.ILoggerInternalMessageFormat.lsklogweb; | ||
if ((0, _logrus.isLogrus)(json)) return _types.ILoggerInternalMessageFormat.logrus; | ||
return null; | ||
@@ -56,5 +58,4 @@ } | ||
function parse(json) { | ||
var format = detectFormat(json); // console.log({ format }); | ||
if (format === 'buyan') return (0, _bunyan.parseBunyan)(json); | ||
var format = detectFormat(json); | ||
if (format === 'bunyan') return (0, _bunyan.parseBunyan)(json); | ||
if (format === 'lsklogweb') return (0, _lsklog.parseLsklog)(json); | ||
@@ -64,2 +65,3 @@ if (format === 'lsklog') return (0, _lsklog.parseLsklog)(json); | ||
return { | ||
format: format, | ||
meta: {}, | ||
@@ -66,0 +68,0 @@ args: [json] |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _ = require("../.."); | ||
var _toString = require("../toString"); | ||
@@ -51,2 +53,3 @@ | ||
return { | ||
format: _.ILoggerInternalMessageFormat.logrus, | ||
meta: { | ||
@@ -53,0 +56,0 @@ level: levelMap[level], |
@@ -14,2 +14,4 @@ "use strict"; | ||
var _ = require("../.."); | ||
var _toString = require("../toString"); | ||
@@ -69,2 +71,3 @@ | ||
return { | ||
format: _.ILoggerInternalMessageFormat.lsklogweb, | ||
meta: meta, | ||
@@ -86,2 +89,3 @@ args: (0, _utils.parseArgs)(msg, data) | ||
return { | ||
format: _.ILoggerInternalMessageFormat.lsklog, | ||
meta: _objectSpread(_objectSpread({}, meta), {}, { | ||
@@ -88,0 +92,0 @@ method: method, |
@@ -15,2 +15,3 @@ "use strict"; | ||
if (typeof str !== 'string') return str; | ||
if (!str.trim()) return defaultValue; | ||
return logfmt.parse(str); | ||
@@ -17,0 +18,0 @@ } catch (err) { |
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
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
Sorry, the diff of this file is not supported yet
268272
2470