@verdaccio/logger 9.0.0-next-9.3 → 9.0.0-next-9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1121 -0
- package/build/_virtual/_rolldown/runtime.js +23 -0
- package/build/_virtual/_rolldown/runtime.mjs +7 -0
- package/build/colors.d.ts +1 -0
- package/build/colors.js +11 -0
- package/build/colors.js.map +1 -0
- package/build/colors.mjs +10 -0
- package/build/colors.mjs.map +1 -0
- package/build/formatter.d.ts +10 -0
- package/build/formatter.js +47 -0
- package/build/formatter.js.map +1 -0
- package/build/formatter.mjs +45 -0
- package/build/formatter.mjs.map +1 -0
- package/build/index.d.ts +13 -2
- package/build/index.js +43 -15
- package/build/index.js.map +1 -1
- package/build/index.mjs +21 -0
- package/build/index.mjs.map +1 -0
- package/build/levels.d.ts +35 -0
- package/build/levels.js +53 -0
- package/build/levels.js.map +1 -0
- package/build/levels.mjs +50 -0
- package/build/levels.mjs.map +1 -0
- package/build/logger.d.ts +9 -0
- package/build/logger.js +86 -0
- package/build/logger.js.map +1 -0
- package/build/logger.mjs +82 -0
- package/build/logger.mjs.map +1 -0
- package/build/prettify.d.ts +20 -0
- package/build/prettify.js +91 -0
- package/build/prettify.js.map +1 -0
- package/build/prettify.mjs +86 -0
- package/build/prettify.mjs.map +1 -0
- package/build/transport.d.ts +6 -0
- package/build/transport.js +33 -0
- package/build/transport.js.map +1 -0
- package/build/transport.mjs +31 -0
- package/build/transport.mjs.map +1 -0
- package/build/types.d.ts +5 -0
- package/build/utils.d.ts +5 -0
- package/build/utils.js +20 -0
- package/build/utils.js.map +1 -0
- package/build/utils.mjs +16 -0
- package/build/utils.mjs.map +1 -0
- package/package.json +30 -11
- package/src/colors.ts +8 -0
- package/src/formatter.ts +90 -0
- package/src/index.ts +28 -0
- package/src/levels.ts +60 -0
- package/src/logger.ts +126 -0
- package/src/prettify.ts +119 -0
- package/src/transport.ts +39 -0
- package/src/types.ts +6 -0
- package/src/utils.ts +18 -0
- package/test/__snapshots__/formatter.spec.ts.snap +21 -0
- package/test/createLogger.spec.ts +22 -0
- package/test/formatter.spec.ts +214 -0
- package/test/index.spec.ts +49 -0
- package/test/logger.spec.ts +368 -0
- package/test/prettify.spec.ts +387 -0
- package/test/transport.spec.ts +108 -0
- package/test/utils.test.ts +19 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +16 -0
- package/vite.config.mjs +3 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
exports.__toESM = __toESM;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
3
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
4
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
5
|
+
});
|
|
6
|
+
//#endregion
|
|
7
|
+
export { __require };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hasColors(colors: boolean | undefined): boolean;
|
package/build/colors.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let colorette = require("colorette");
|
|
3
|
+
//#region src/colors.ts
|
|
4
|
+
function hasColors(colors) {
|
|
5
|
+
if (colors) return colorette.isColorSupported;
|
|
6
|
+
return typeof colors === "undefined" ? true : colors;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
exports.hasColors = hasColors;
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=colors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.js","names":[],"sources":["../src/colors.ts"],"sourcesContent":["import { isColorSupported } from 'colorette';\n\nexport function hasColors(colors: boolean | undefined) {\n if (colors) {\n return isColorSupported;\n }\n return typeof colors === 'undefined' ? true : colors;\n}\n"],"mappings":";;;AAEA,SAAgB,UAAU,QAA6B;AACrD,KAAI,OACF,QAAO,UAAA;AAET,QAAO,OAAO,WAAW,cAAc,OAAO"}
|
package/build/colors.mjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { isColorSupported } from "colorette";
|
|
2
|
+
//#region src/colors.ts
|
|
3
|
+
function hasColors(colors) {
|
|
4
|
+
if (colors) return isColorSupported;
|
|
5
|
+
return typeof colors === "undefined" ? true : colors;
|
|
6
|
+
}
|
|
7
|
+
//#endregion
|
|
8
|
+
export { hasColors };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=colors.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.mjs","names":[],"sources":["../src/colors.ts"],"sourcesContent":["import { isColorSupported } from 'colorette';\n\nexport function hasColors(colors: boolean | undefined) {\n if (colors) {\n return isColorSupported;\n }\n return typeof colors === 'undefined' ? true : colors;\n}\n"],"mappings":";;AAEA,SAAgB,UAAU,QAA6B;AACrD,KAAI,OACF,QAAO;AAET,QAAO,OAAO,WAAW,cAAc,OAAO"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LevelCode } from './levels';
|
|
2
|
+
import { PrettyOptionsExtended } from './types';
|
|
3
|
+
export interface ObjectTemplate {
|
|
4
|
+
level: LevelCode;
|
|
5
|
+
msg: string;
|
|
6
|
+
sub?: string;
|
|
7
|
+
[key: string]: string | number | object | null | void;
|
|
8
|
+
}
|
|
9
|
+
export declare function fillInMsgTemplate(msg: string, templateOptions: ObjectTemplate, colors: boolean): string;
|
|
10
|
+
export declare function printMessage(templateObjects: ObjectTemplate, options: Pick<PrettyOptionsExtended, 'prettyStamp'>, hasColors: boolean): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_levels = require("./levels.js");
|
|
3
|
+
const require_utils = require("./utils.js");
|
|
4
|
+
let colorette = require("colorette");
|
|
5
|
+
let node_util = require("node:util");
|
|
6
|
+
//#region src/formatter.ts
|
|
7
|
+
var LEVEL_VALUE_MAX = 0;
|
|
8
|
+
for (const l of Object.keys(require_levels.levelsColors)) LEVEL_VALUE_MAX = Math.max(LEVEL_VALUE_MAX, l.length);
|
|
9
|
+
var ERROR_FLAG = "!";
|
|
10
|
+
function fillInMsgTemplate(msg, templateOptions, colors) {
|
|
11
|
+
return msg.replace(/@{(!?[$A-Za-z_][$0-9A-Za-z\._]*)}/g, (_, name) => {
|
|
12
|
+
let str = templateOptions;
|
|
13
|
+
let isError;
|
|
14
|
+
if (name[0] === ERROR_FLAG) {
|
|
15
|
+
name = name.slice(1);
|
|
16
|
+
isError = true;
|
|
17
|
+
}
|
|
18
|
+
const listAccessors = name.split(".");
|
|
19
|
+
for (let property = 0; property < listAccessors.length; property++) {
|
|
20
|
+
const id = listAccessors[property];
|
|
21
|
+
if (require_utils.isObject(str)) str = str[id];
|
|
22
|
+
}
|
|
23
|
+
if (typeof str === "string") {
|
|
24
|
+
if (colors === false || str.includes("\n")) return str;
|
|
25
|
+
else if (isError) return (0, colorette.red)(str);
|
|
26
|
+
return (0, colorette.green)(str);
|
|
27
|
+
}
|
|
28
|
+
return (0, node_util.inspect)(str, void 0, null, colors);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function getMessage(debugLevel, msg, sub, templateObjects, hasColors) {
|
|
32
|
+
const finalMessage = fillInMsgTemplate(msg, templateObjects, hasColors);
|
|
33
|
+
const subSystemType = hasColors ? require_levels.subSystemLevels.color[sub ?? "default"] : require_levels.subSystemLevels.white[sub ?? "default"];
|
|
34
|
+
if (hasColors) return `${require_levels.levelsColors[debugLevel](require_utils.padRight(debugLevel, LEVEL_VALUE_MAX))}${(0, colorette.white)(`${subSystemType} ${finalMessage}`)}`;
|
|
35
|
+
return `${require_utils.padRight(debugLevel, LEVEL_VALUE_MAX)}${subSystemType} ${finalMessage}`;
|
|
36
|
+
}
|
|
37
|
+
function printMessage(templateObjects, options, hasColors) {
|
|
38
|
+
const { prettyStamp } = options;
|
|
39
|
+
const { level, msg, sub } = templateObjects;
|
|
40
|
+
const logMessage = getMessage(require_levels.calculateLevel(level), msg, sub, templateObjects, hasColors);
|
|
41
|
+
return prettyStamp ? require_utils.formatLoggingDate(templateObjects.time, logMessage) : logMessage;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.fillInMsgTemplate = fillInMsgTemplate;
|
|
45
|
+
exports.printMessage = printMessage;
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=formatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.js","names":[],"sources":["../src/formatter.ts"],"sourcesContent":["import { green, red, white } from 'colorette';\nimport { inspect } from 'node:util';\n\nimport type { LevelCode } from './levels';\nimport { calculateLevel, levelsColors, subSystemLevels } from './levels';\nimport type { PrettyOptionsExtended } from './types';\nimport { formatLoggingDate, isObject, padRight } from './utils';\n\nlet LEVEL_VALUE_MAX = 0;\nfor (const l of Object.keys(levelsColors)) {\n LEVEL_VALUE_MAX = Math.max(LEVEL_VALUE_MAX, l.length);\n}\n\nconst ERROR_FLAG = '!';\n\nexport interface ObjectTemplate {\n level: LevelCode;\n msg: string;\n sub?: string;\n [key: string]: string | number | object | null | void;\n}\n\nexport function fillInMsgTemplate(\n msg: string,\n templateOptions: ObjectTemplate,\n colors: boolean\n): string {\n const templateRegex = /@{(!?[$A-Za-z_][$0-9A-Za-z\\._]*)}/g;\n\n return msg.replace(templateRegex, (_, name): string => {\n let str = templateOptions;\n let isError;\n if (name[0] === ERROR_FLAG) {\n name = name.slice(1);\n isError = true;\n }\n\n // object can be @{foo.bar.}\n const listAccessors = name.split('.');\n for (let property = 0; property < listAccessors.length; property++) {\n const id = listAccessors[property];\n if (isObject(str)) {\n str = (str as object)[id];\n }\n }\n\n if (typeof str === 'string') {\n if (colors === false || (str as string).includes('\\n')) {\n return str;\n } else if (isError) {\n return red(str);\n }\n return green(str);\n }\n\n // object, showHidden, depth, colors\n return inspect(str, undefined, null, colors);\n });\n}\n\nfunction getMessage(debugLevel, msg, sub, templateObjects, hasColors: boolean) {\n const finalMessage = fillInMsgTemplate(msg, templateObjects, hasColors);\n\n const subSystemType = hasColors\n ? subSystemLevels.color[sub ?? 'default']\n : subSystemLevels.white[sub ?? 'default'];\n if (hasColors) {\n const logString = `${levelsColors[debugLevel](padRight(debugLevel, LEVEL_VALUE_MAX))}${white(\n `${subSystemType} ${finalMessage}`\n )}`;\n\n return logString;\n }\n const logString = `${padRight(debugLevel, LEVEL_VALUE_MAX)}${subSystemType} ${finalMessage}`;\n\n return logString;\n}\n\nexport function printMessage(\n templateObjects: ObjectTemplate,\n options: Pick<PrettyOptionsExtended, 'prettyStamp'>,\n hasColors: boolean\n): string {\n const { prettyStamp } = options;\n const { level, msg, sub } = templateObjects;\n const debugLevel = calculateLevel(level);\n const logMessage = getMessage(debugLevel, msg, sub, templateObjects, hasColors);\n\n return prettyStamp ? formatLoggingDate(templateObjects.time as number, logMessage) : logMessage;\n}\n"],"mappings":";;;;;;AAQA,IAAI,kBAAkB;AACtB,KAAK,MAAM,KAAK,OAAO,KAAK,eAAA,aAAa,CACvC,mBAAkB,KAAK,IAAI,iBAAiB,EAAE,OAAO;AAGvD,IAAM,aAAa;AASnB,SAAgB,kBACd,KACA,iBACA,QACQ;AAGR,QAAO,IAAI,QAFW,uCAEa,GAAG,SAAiB;EACrD,IAAI,MAAM;EACV,IAAI;AACJ,MAAI,KAAK,OAAO,YAAY;AAC1B,UAAO,KAAK,MAAM,EAAE;AACpB,aAAU;;EAIZ,MAAM,gBAAgB,KAAK,MAAM,IAAI;AACrC,OAAK,IAAI,WAAW,GAAG,WAAW,cAAc,QAAQ,YAAY;GAClE,MAAM,KAAK,cAAc;AACzB,OAAI,cAAA,SAAS,IAAI,CACf,OAAO,IAAe;;AAI1B,MAAI,OAAO,QAAQ,UAAU;AAC3B,OAAI,WAAW,SAAU,IAAe,SAAS,KAAK,CACpD,QAAO;YACE,QACT,SAAA,GAAA,UAAA,KAAW,IAAI;AAEjB,WAAA,GAAA,UAAA,OAAa,IAAI;;AAInB,UAAA,GAAA,UAAA,SAAe,KAAK,KAAA,GAAW,MAAM,OAAO;GAC5C;;AAGJ,SAAS,WAAW,YAAY,KAAK,KAAK,iBAAiB,WAAoB;CAC7E,MAAM,eAAe,kBAAkB,KAAK,iBAAiB,UAAU;CAEvE,MAAM,gBAAgB,YAClB,eAAA,gBAAgB,MAAM,OAAO,aAC7B,eAAA,gBAAgB,MAAM,OAAO;AACjC,KAAI,UAKF,QAJkB,GAAG,eAAA,aAAa,YAAY,cAAA,SAAS,YAAY,gBAAgB,CAAC,IAAA,GAAA,UAAA,OAClF,GAAG,cAAc,GAAG,eACrB;AAMH,QAFkB,GAAG,cAAA,SAAS,YAAY,gBAAgB,GAAG,cAAc,GAAG;;AAKhF,SAAgB,aACd,iBACA,SACA,WACQ;CACR,MAAM,EAAE,gBAAgB;CACxB,MAAM,EAAE,OAAO,KAAK,QAAQ;CAE5B,MAAM,aAAa,WADA,eAAA,eAAe,MAAM,EACE,KAAK,KAAK,iBAAiB,UAAU;AAE/E,QAAO,cAAc,cAAA,kBAAkB,gBAAgB,MAAgB,WAAW,GAAG"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { calculateLevel, levelsColors, subSystemLevels } from "./levels.mjs";
|
|
2
|
+
import { formatLoggingDate, isObject, padRight } from "./utils.mjs";
|
|
3
|
+
import { green, red, white } from "colorette";
|
|
4
|
+
import { inspect } from "node:util";
|
|
5
|
+
//#region src/formatter.ts
|
|
6
|
+
var LEVEL_VALUE_MAX = 0;
|
|
7
|
+
for (const l of Object.keys(levelsColors)) LEVEL_VALUE_MAX = Math.max(LEVEL_VALUE_MAX, l.length);
|
|
8
|
+
var ERROR_FLAG = "!";
|
|
9
|
+
function fillInMsgTemplate(msg, templateOptions, colors) {
|
|
10
|
+
return msg.replace(/@{(!?[$A-Za-z_][$0-9A-Za-z\._]*)}/g, (_, name) => {
|
|
11
|
+
let str = templateOptions;
|
|
12
|
+
let isError;
|
|
13
|
+
if (name[0] === ERROR_FLAG) {
|
|
14
|
+
name = name.slice(1);
|
|
15
|
+
isError = true;
|
|
16
|
+
}
|
|
17
|
+
const listAccessors = name.split(".");
|
|
18
|
+
for (let property = 0; property < listAccessors.length; property++) {
|
|
19
|
+
const id = listAccessors[property];
|
|
20
|
+
if (isObject(str)) str = str[id];
|
|
21
|
+
}
|
|
22
|
+
if (typeof str === "string") {
|
|
23
|
+
if (colors === false || str.includes("\n")) return str;
|
|
24
|
+
else if (isError) return red(str);
|
|
25
|
+
return green(str);
|
|
26
|
+
}
|
|
27
|
+
return inspect(str, void 0, null, colors);
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function getMessage(debugLevel, msg, sub, templateObjects, hasColors) {
|
|
31
|
+
const finalMessage = fillInMsgTemplate(msg, templateObjects, hasColors);
|
|
32
|
+
const subSystemType = hasColors ? subSystemLevels.color[sub ?? "default"] : subSystemLevels.white[sub ?? "default"];
|
|
33
|
+
if (hasColors) return `${levelsColors[debugLevel](padRight(debugLevel, LEVEL_VALUE_MAX))}${white(`${subSystemType} ${finalMessage}`)}`;
|
|
34
|
+
return `${padRight(debugLevel, LEVEL_VALUE_MAX)}${subSystemType} ${finalMessage}`;
|
|
35
|
+
}
|
|
36
|
+
function printMessage(templateObjects, options, hasColors) {
|
|
37
|
+
const { prettyStamp } = options;
|
|
38
|
+
const { level, msg, sub } = templateObjects;
|
|
39
|
+
const logMessage = getMessage(calculateLevel(level), msg, sub, templateObjects, hasColors);
|
|
40
|
+
return prettyStamp ? formatLoggingDate(templateObjects.time, logMessage) : logMessage;
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { fillInMsgTemplate, printMessage };
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=formatter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatter.mjs","names":[],"sources":["../src/formatter.ts"],"sourcesContent":["import { green, red, white } from 'colorette';\nimport { inspect } from 'node:util';\n\nimport type { LevelCode } from './levels';\nimport { calculateLevel, levelsColors, subSystemLevels } from './levels';\nimport type { PrettyOptionsExtended } from './types';\nimport { formatLoggingDate, isObject, padRight } from './utils';\n\nlet LEVEL_VALUE_MAX = 0;\nfor (const l of Object.keys(levelsColors)) {\n LEVEL_VALUE_MAX = Math.max(LEVEL_VALUE_MAX, l.length);\n}\n\nconst ERROR_FLAG = '!';\n\nexport interface ObjectTemplate {\n level: LevelCode;\n msg: string;\n sub?: string;\n [key: string]: string | number | object | null | void;\n}\n\nexport function fillInMsgTemplate(\n msg: string,\n templateOptions: ObjectTemplate,\n colors: boolean\n): string {\n const templateRegex = /@{(!?[$A-Za-z_][$0-9A-Za-z\\._]*)}/g;\n\n return msg.replace(templateRegex, (_, name): string => {\n let str = templateOptions;\n let isError;\n if (name[0] === ERROR_FLAG) {\n name = name.slice(1);\n isError = true;\n }\n\n // object can be @{foo.bar.}\n const listAccessors = name.split('.');\n for (let property = 0; property < listAccessors.length; property++) {\n const id = listAccessors[property];\n if (isObject(str)) {\n str = (str as object)[id];\n }\n }\n\n if (typeof str === 'string') {\n if (colors === false || (str as string).includes('\\n')) {\n return str;\n } else if (isError) {\n return red(str);\n }\n return green(str);\n }\n\n // object, showHidden, depth, colors\n return inspect(str, undefined, null, colors);\n });\n}\n\nfunction getMessage(debugLevel, msg, sub, templateObjects, hasColors: boolean) {\n const finalMessage = fillInMsgTemplate(msg, templateObjects, hasColors);\n\n const subSystemType = hasColors\n ? subSystemLevels.color[sub ?? 'default']\n : subSystemLevels.white[sub ?? 'default'];\n if (hasColors) {\n const logString = `${levelsColors[debugLevel](padRight(debugLevel, LEVEL_VALUE_MAX))}${white(\n `${subSystemType} ${finalMessage}`\n )}`;\n\n return logString;\n }\n const logString = `${padRight(debugLevel, LEVEL_VALUE_MAX)}${subSystemType} ${finalMessage}`;\n\n return logString;\n}\n\nexport function printMessage(\n templateObjects: ObjectTemplate,\n options: Pick<PrettyOptionsExtended, 'prettyStamp'>,\n hasColors: boolean\n): string {\n const { prettyStamp } = options;\n const { level, msg, sub } = templateObjects;\n const debugLevel = calculateLevel(level);\n const logMessage = getMessage(debugLevel, msg, sub, templateObjects, hasColors);\n\n return prettyStamp ? formatLoggingDate(templateObjects.time as number, logMessage) : logMessage;\n}\n"],"mappings":";;;;;AAQA,IAAI,kBAAkB;AACtB,KAAK,MAAM,KAAK,OAAO,KAAK,aAAa,CACvC,mBAAkB,KAAK,IAAI,iBAAiB,EAAE,OAAO;AAGvD,IAAM,aAAa;AASnB,SAAgB,kBACd,KACA,iBACA,QACQ;AAGR,QAAO,IAAI,QAFW,uCAEa,GAAG,SAAiB;EACrD,IAAI,MAAM;EACV,IAAI;AACJ,MAAI,KAAK,OAAO,YAAY;AAC1B,UAAO,KAAK,MAAM,EAAE;AACpB,aAAU;;EAIZ,MAAM,gBAAgB,KAAK,MAAM,IAAI;AACrC,OAAK,IAAI,WAAW,GAAG,WAAW,cAAc,QAAQ,YAAY;GAClE,MAAM,KAAK,cAAc;AACzB,OAAI,SAAS,IAAI,CACf,OAAO,IAAe;;AAI1B,MAAI,OAAO,QAAQ,UAAU;AAC3B,OAAI,WAAW,SAAU,IAAe,SAAS,KAAK,CACpD,QAAO;YACE,QACT,QAAO,IAAI,IAAI;AAEjB,UAAO,MAAM,IAAI;;AAInB,SAAO,QAAQ,KAAK,KAAA,GAAW,MAAM,OAAO;GAC5C;;AAGJ,SAAS,WAAW,YAAY,KAAK,KAAK,iBAAiB,WAAoB;CAC7E,MAAM,eAAe,kBAAkB,KAAK,iBAAiB,UAAU;CAEvE,MAAM,gBAAgB,YAClB,gBAAgB,MAAM,OAAO,aAC7B,gBAAgB,MAAM,OAAO;AACjC,KAAI,UAKF,QAJkB,GAAG,aAAa,YAAY,SAAS,YAAY,gBAAgB,CAAC,GAAG,MACrF,GAAG,cAAc,GAAG,eACrB;AAMH,QAFkB,GAAG,SAAS,YAAY,gBAAgB,GAAG,cAAc,GAAG;;AAKhF,SAAgB,aACd,iBACA,SACA,WACQ;CACR,MAAM,EAAE,gBAAgB;CACxB,MAAM,EAAE,OAAO,KAAK,QAAQ;CAE5B,MAAM,aAAa,WADA,eAAe,MAAM,EACE,KAAK,KAAK,iBAAiB,UAAU;AAE/E,QAAO,cAAc,kBAAkB,gBAAgB,MAAgB,WAAW,GAAG"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
1
|
+
import { Logger, LoggerConfigItem } from '@verdaccio/types';
|
|
2
|
+
export { createLogger, prepareSetup, willUseTransport } from './logger';
|
|
3
|
+
export type { LogPlugin, LoggerConfig } from './logger';
|
|
4
|
+
export { default as prettifyTransport, autoEnd, buildPretty, buildSafeSonicBoom } from './prettify';
|
|
5
|
+
export { hasColors } from './colors';
|
|
6
|
+
export { fillInMsgTemplate, printMessage } from './formatter';
|
|
7
|
+
export { createPrettyTransport, isPrettyFormat } from './transport';
|
|
8
|
+
export type { LevelCode } from './levels';
|
|
9
|
+
export { formatLoggingDate, padRight } from './utils';
|
|
10
|
+
/**
|
|
11
|
+
* Initialize the logger singleton.
|
|
12
|
+
*/
|
|
13
|
+
export declare function setup(options: LoggerConfigItem): Promise<Logger>;
|
|
3
14
|
export declare let logger: Logger;
|
package/build/index.js
CHANGED
|
@@ -1,19 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
4
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
6
|
+
const require_utils = require("./utils.js");
|
|
7
|
+
const require_formatter = require("./formatter.js");
|
|
8
|
+
const require_colors = require("./colors.js");
|
|
9
|
+
const require_transport = require("./transport.js");
|
|
10
|
+
const require_logger = require("./logger.js");
|
|
11
|
+
const require_prettify = require("./prettify.js");
|
|
12
|
+
let pino = require("pino");
|
|
13
|
+
pino = require_runtime.__toESM(pino);
|
|
14
|
+
//#region src/index.ts
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the logger singleton.
|
|
17
|
+
*/
|
|
18
|
+
async function setup(options) {
|
|
19
|
+
if (typeof logger !== "undefined") return logger;
|
|
20
|
+
logger = await require_logger.prepareSetup(options, pino.default);
|
|
21
|
+
return logger;
|
|
17
22
|
}
|
|
18
23
|
var logger;
|
|
24
|
+
//#endregion
|
|
25
|
+
exports.autoEnd = require_prettify.autoEnd;
|
|
26
|
+
exports.buildPretty = require_prettify.buildPretty;
|
|
27
|
+
exports.buildSafeSonicBoom = require_prettify.buildSafeSonicBoom;
|
|
28
|
+
exports.createLogger = require_logger.createLogger;
|
|
29
|
+
exports.createPrettyTransport = require_transport.createPrettyTransport;
|
|
30
|
+
exports.fillInMsgTemplate = require_formatter.fillInMsgTemplate;
|
|
31
|
+
exports.formatLoggingDate = require_utils.formatLoggingDate;
|
|
32
|
+
exports.hasColors = require_colors.hasColors;
|
|
33
|
+
exports.isPrettyFormat = require_transport.isPrettyFormat;
|
|
34
|
+
Object.defineProperty(exports, "logger", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function() {
|
|
37
|
+
return logger;
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
exports.padRight = require_utils.padRight;
|
|
41
|
+
exports.prepareSetup = require_logger.prepareSetup;
|
|
42
|
+
exports.prettifyTransport = require_prettify.default;
|
|
43
|
+
exports.printMessage = require_formatter.printMessage;
|
|
44
|
+
exports.setup = setup;
|
|
45
|
+
exports.willUseTransport = require_logger.willUseTransport;
|
|
46
|
+
|
|
19
47
|
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import pino from 'pino';\n\nimport type { Logger, LoggerConfigItem } from '@verdaccio/types';\n\nimport { prepareSetup } from './logger';\n\nexport { createLogger, prepareSetup, willUseTransport } from './logger';\nexport type { LogPlugin, LoggerConfig } from './logger';\nexport { default as prettifyTransport, autoEnd, buildPretty, buildSafeSonicBoom } from './prettify';\nexport { hasColors } from './colors';\nexport { fillInMsgTemplate, printMessage } from './formatter';\nexport { createPrettyTransport, isPrettyFormat } from './transport';\nexport type { LevelCode } from './levels';\nexport { formatLoggingDate, padRight } from './utils';\n\n/**\n * Initialize the logger singleton.\n */\nexport async function setup(options: LoggerConfigItem): Promise<Logger> {\n if (typeof logger !== 'undefined') {\n return logger;\n }\n\n logger = await prepareSetup(options, pino);\n return logger;\n}\n\nexport let logger: Logger;\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,eAAsB,MAAM,SAA4C;AACtE,KAAI,OAAO,WAAW,YACpB,QAAO;AAGT,UAAS,MAAM,eAAA,aAAa,SAAS,KAAA,QAAK;AAC1C,QAAO;;AAGT,IAAW"}
|
package/build/index.mjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { formatLoggingDate, padRight } from "./utils.mjs";
|
|
2
|
+
import { fillInMsgTemplate, printMessage } from "./formatter.mjs";
|
|
3
|
+
import { hasColors } from "./colors.mjs";
|
|
4
|
+
import { createPrettyTransport, isPrettyFormat } from "./transport.mjs";
|
|
5
|
+
import { createLogger, prepareSetup, willUseTransport } from "./logger.mjs";
|
|
6
|
+
import prettify_default, { autoEnd, buildPretty, buildSafeSonicBoom } from "./prettify.mjs";
|
|
7
|
+
import pino from "pino";
|
|
8
|
+
//#region src/index.ts
|
|
9
|
+
/**
|
|
10
|
+
* Initialize the logger singleton.
|
|
11
|
+
*/
|
|
12
|
+
async function setup(options) {
|
|
13
|
+
if (typeof logger !== "undefined") return logger;
|
|
14
|
+
logger = await prepareSetup(options, pino);
|
|
15
|
+
return logger;
|
|
16
|
+
}
|
|
17
|
+
var logger;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { autoEnd, buildPretty, buildSafeSonicBoom, createLogger, createPrettyTransport, fillInMsgTemplate, formatLoggingDate, hasColors, isPrettyFormat, logger, padRight, prepareSetup, prettify_default as prettifyTransport, printMessage, setup, willUseTransport };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import pino from 'pino';\n\nimport type { Logger, LoggerConfigItem } from '@verdaccio/types';\n\nimport { prepareSetup } from './logger';\n\nexport { createLogger, prepareSetup, willUseTransport } from './logger';\nexport type { LogPlugin, LoggerConfig } from './logger';\nexport { default as prettifyTransport, autoEnd, buildPretty, buildSafeSonicBoom } from './prettify';\nexport { hasColors } from './colors';\nexport { fillInMsgTemplate, printMessage } from './formatter';\nexport { createPrettyTransport, isPrettyFormat } from './transport';\nexport type { LevelCode } from './levels';\nexport { formatLoggingDate, padRight } from './utils';\n\n/**\n * Initialize the logger singleton.\n */\nexport async function setup(options: LoggerConfigItem): Promise<Logger> {\n if (typeof logger !== 'undefined') {\n return logger;\n }\n\n logger = await prepareSetup(options, pino);\n return logger;\n}\n\nexport let logger: Logger;\n"],"mappings":";;;;;;;;;;;AAkBA,eAAsB,MAAM,SAA4C;AACtE,KAAI,OAAO,WAAW,YACpB,QAAO;AAGT,UAAS,MAAM,aAAa,SAAS,KAAK;AAC1C,QAAO;;AAGT,IAAW"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type LogLevel = 'trace' | 'debug' | 'info' | 'http' | 'warn' | 'error' | 'fatal';
|
|
2
|
+
export type LevelCode = number;
|
|
3
|
+
export declare function calculateLevel(levelCode: LevelCode): LogLevel;
|
|
4
|
+
export declare const levelsColors: {
|
|
5
|
+
fatal: import('colorette').Color;
|
|
6
|
+
error: import('colorette').Color;
|
|
7
|
+
warn: import('colorette').Color;
|
|
8
|
+
http: import('colorette').Color;
|
|
9
|
+
info: import('colorette').Color;
|
|
10
|
+
debug: import('colorette').Color;
|
|
11
|
+
trace: import('colorette').Color;
|
|
12
|
+
};
|
|
13
|
+
declare enum ARROWS {
|
|
14
|
+
LEFT = "<--",
|
|
15
|
+
RIGHT = "-->",
|
|
16
|
+
EQUAL = "-=-",
|
|
17
|
+
NEUTRAL = "---"
|
|
18
|
+
}
|
|
19
|
+
export declare const subSystemLevels: {
|
|
20
|
+
color: {
|
|
21
|
+
in: string;
|
|
22
|
+
out: string;
|
|
23
|
+
auth: string;
|
|
24
|
+
fs: string;
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
white: {
|
|
28
|
+
in: ARROWS;
|
|
29
|
+
out: ARROWS;
|
|
30
|
+
auth: ARROWS;
|
|
31
|
+
fs: ARROWS;
|
|
32
|
+
default: ARROWS;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export {};
|
package/build/levels.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let colorette = require("colorette");
|
|
3
|
+
//#region src/levels.ts
|
|
4
|
+
function calculateLevel(levelCode) {
|
|
5
|
+
switch (true) {
|
|
6
|
+
case levelCode === 10: return "trace";
|
|
7
|
+
case levelCode === 20: return "debug";
|
|
8
|
+
case levelCode === 25: return "http";
|
|
9
|
+
case levelCode === 30: return "info";
|
|
10
|
+
case levelCode === 40: return "warn";
|
|
11
|
+
case levelCode === 50: return "error";
|
|
12
|
+
case levelCode === 60: return "fatal";
|
|
13
|
+
default: return "fatal";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
var levelsColors = {
|
|
17
|
+
fatal: colorette.red,
|
|
18
|
+
error: colorette.red,
|
|
19
|
+
warn: colorette.yellow,
|
|
20
|
+
http: colorette.magenta,
|
|
21
|
+
info: colorette.cyan,
|
|
22
|
+
debug: colorette.green,
|
|
23
|
+
trace: colorette.white
|
|
24
|
+
};
|
|
25
|
+
var ARROWS = /* @__PURE__ */ function(ARROWS) {
|
|
26
|
+
ARROWS["LEFT"] = "<--";
|
|
27
|
+
ARROWS["RIGHT"] = "-->";
|
|
28
|
+
ARROWS["EQUAL"] = "-=-";
|
|
29
|
+
ARROWS["NEUTRAL"] = "---";
|
|
30
|
+
return ARROWS;
|
|
31
|
+
}(ARROWS || {});
|
|
32
|
+
var subSystemLevels = {
|
|
33
|
+
color: {
|
|
34
|
+
in: (0, colorette.green)(ARROWS.LEFT),
|
|
35
|
+
out: (0, colorette.yellow)(ARROWS.RIGHT),
|
|
36
|
+
auth: (0, colorette.blue)(ARROWS.NEUTRAL),
|
|
37
|
+
fs: (0, colorette.black)(ARROWS.EQUAL),
|
|
38
|
+
default: (0, colorette.blue)(ARROWS.NEUTRAL)
|
|
39
|
+
},
|
|
40
|
+
white: {
|
|
41
|
+
in: ARROWS.LEFT,
|
|
42
|
+
out: ARROWS.RIGHT,
|
|
43
|
+
auth: ARROWS.NEUTRAL,
|
|
44
|
+
fs: ARROWS.EQUAL,
|
|
45
|
+
default: ARROWS.NEUTRAL
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
exports.calculateLevel = calculateLevel;
|
|
50
|
+
exports.levelsColors = levelsColors;
|
|
51
|
+
exports.subSystemLevels = subSystemLevels;
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=levels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"levels.js","names":[],"sources":["../src/levels.ts"],"sourcesContent":["import { black, blue, cyan, green, magenta, red, white, yellow } from 'colorette';\n\nexport type LogLevel = 'trace' | 'debug' | 'info' | 'http' | 'warn' | 'error' | 'fatal';\n\nexport type LevelCode = number;\n\nexport function calculateLevel(levelCode: LevelCode): LogLevel {\n switch (true) {\n case levelCode === 10:\n return 'trace';\n case levelCode === 20:\n return 'debug';\n case levelCode === 25:\n return 'http';\n case levelCode === 30:\n return 'info';\n case levelCode === 40:\n return 'warn';\n case levelCode === 50:\n return 'error';\n case levelCode === 60:\n return 'fatal';\n default:\n return 'fatal';\n }\n}\n\nexport const levelsColors = {\n fatal: red,\n error: red,\n warn: yellow,\n http: magenta,\n info: cyan,\n debug: green,\n trace: white,\n};\n\nenum ARROWS {\n LEFT = '<--',\n RIGHT = '-->',\n EQUAL = '-=-',\n NEUTRAL = '---',\n}\n\nexport const subSystemLevels = {\n color: {\n in: green(ARROWS.LEFT),\n out: yellow(ARROWS.RIGHT),\n auth: blue(ARROWS.NEUTRAL),\n fs: black(ARROWS.EQUAL),\n default: blue(ARROWS.NEUTRAL),\n },\n white: {\n in: ARROWS.LEFT,\n out: ARROWS.RIGHT,\n auth: ARROWS.NEUTRAL,\n fs: ARROWS.EQUAL,\n default: ARROWS.NEUTRAL,\n },\n};\n"],"mappings":";;;AAMA,SAAgB,eAAe,WAAgC;AAC7D,SAAQ,MAAR;EACE,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,QACE,QAAO;;;AAIb,IAAa,eAAe;CAC1B,OAAO,UAAA;CACP,OAAO,UAAA;CACP,MAAM,UAAA;CACN,MAAM,UAAA;CACN,MAAM,UAAA;CACN,OAAO,UAAA;CACP,OAAO,UAAA;CACR;AAED,IAAK,SAAL,yBAAA,QAAA;AACE,QAAA,UAAA;AACA,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,aAAA;;EAJG,UAAA,EAAA,CAKJ;AAED,IAAa,kBAAkB;CAC7B,OAAO;EACL,KAAA,GAAA,UAAA,OAAU,OAAO,KAAK;EACtB,MAAA,GAAA,UAAA,QAAY,OAAO,MAAM;EACzB,OAAA,GAAA,UAAA,MAAW,OAAO,QAAQ;EAC1B,KAAA,GAAA,UAAA,OAAU,OAAO,MAAM;EACvB,UAAA,GAAA,UAAA,MAAc,OAAO,QAAQ;EAC9B;CACD,OAAO;EACL,IAAI,OAAO;EACX,KAAK,OAAO;EACZ,MAAM,OAAO;EACb,IAAI,OAAO;EACX,SAAS,OAAO;EACjB;CACF"}
|
package/build/levels.mjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { black, blue, cyan, green, magenta, red, white, yellow } from "colorette";
|
|
2
|
+
//#region src/levels.ts
|
|
3
|
+
function calculateLevel(levelCode) {
|
|
4
|
+
switch (true) {
|
|
5
|
+
case levelCode === 10: return "trace";
|
|
6
|
+
case levelCode === 20: return "debug";
|
|
7
|
+
case levelCode === 25: return "http";
|
|
8
|
+
case levelCode === 30: return "info";
|
|
9
|
+
case levelCode === 40: return "warn";
|
|
10
|
+
case levelCode === 50: return "error";
|
|
11
|
+
case levelCode === 60: return "fatal";
|
|
12
|
+
default: return "fatal";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
var levelsColors = {
|
|
16
|
+
fatal: red,
|
|
17
|
+
error: red,
|
|
18
|
+
warn: yellow,
|
|
19
|
+
http: magenta,
|
|
20
|
+
info: cyan,
|
|
21
|
+
debug: green,
|
|
22
|
+
trace: white
|
|
23
|
+
};
|
|
24
|
+
var ARROWS = /* @__PURE__ */ function(ARROWS) {
|
|
25
|
+
ARROWS["LEFT"] = "<--";
|
|
26
|
+
ARROWS["RIGHT"] = "-->";
|
|
27
|
+
ARROWS["EQUAL"] = "-=-";
|
|
28
|
+
ARROWS["NEUTRAL"] = "---";
|
|
29
|
+
return ARROWS;
|
|
30
|
+
}(ARROWS || {});
|
|
31
|
+
var subSystemLevels = {
|
|
32
|
+
color: {
|
|
33
|
+
in: green(ARROWS.LEFT),
|
|
34
|
+
out: yellow(ARROWS.RIGHT),
|
|
35
|
+
auth: blue(ARROWS.NEUTRAL),
|
|
36
|
+
fs: black(ARROWS.EQUAL),
|
|
37
|
+
default: blue(ARROWS.NEUTRAL)
|
|
38
|
+
},
|
|
39
|
+
white: {
|
|
40
|
+
in: ARROWS.LEFT,
|
|
41
|
+
out: ARROWS.RIGHT,
|
|
42
|
+
auth: ARROWS.NEUTRAL,
|
|
43
|
+
fs: ARROWS.EQUAL,
|
|
44
|
+
default: ARROWS.NEUTRAL
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
export { calculateLevel, levelsColors, subSystemLevels };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=levels.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"levels.mjs","names":[],"sources":["../src/levels.ts"],"sourcesContent":["import { black, blue, cyan, green, magenta, red, white, yellow } from 'colorette';\n\nexport type LogLevel = 'trace' | 'debug' | 'info' | 'http' | 'warn' | 'error' | 'fatal';\n\nexport type LevelCode = number;\n\nexport function calculateLevel(levelCode: LevelCode): LogLevel {\n switch (true) {\n case levelCode === 10:\n return 'trace';\n case levelCode === 20:\n return 'debug';\n case levelCode === 25:\n return 'http';\n case levelCode === 30:\n return 'info';\n case levelCode === 40:\n return 'warn';\n case levelCode === 50:\n return 'error';\n case levelCode === 60:\n return 'fatal';\n default:\n return 'fatal';\n }\n}\n\nexport const levelsColors = {\n fatal: red,\n error: red,\n warn: yellow,\n http: magenta,\n info: cyan,\n debug: green,\n trace: white,\n};\n\nenum ARROWS {\n LEFT = '<--',\n RIGHT = '-->',\n EQUAL = '-=-',\n NEUTRAL = '---',\n}\n\nexport const subSystemLevels = {\n color: {\n in: green(ARROWS.LEFT),\n out: yellow(ARROWS.RIGHT),\n auth: blue(ARROWS.NEUTRAL),\n fs: black(ARROWS.EQUAL),\n default: blue(ARROWS.NEUTRAL),\n },\n white: {\n in: ARROWS.LEFT,\n out: ARROWS.RIGHT,\n auth: ARROWS.NEUTRAL,\n fs: ARROWS.EQUAL,\n default: ARROWS.NEUTRAL,\n },\n};\n"],"mappings":";;AAMA,SAAgB,eAAe,WAAgC;AAC7D,SAAQ,MAAR;EACE,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,KAAK,cAAc,GACjB,QAAO;EACT,QACE,QAAO;;;AAIb,IAAa,eAAe;CAC1B,OAAO;CACP,OAAO;CACP,MAAM;CACN,MAAM;CACN,MAAM;CACN,OAAO;CACP,OAAO;CACR;AAED,IAAK,SAAL,yBAAA,QAAA;AACE,QAAA,UAAA;AACA,QAAA,WAAA;AACA,QAAA,WAAA;AACA,QAAA,aAAA;;EAJG,UAAA,EAAA,CAKJ;AAED,IAAa,kBAAkB;CAC7B,OAAO;EACL,IAAI,MAAM,OAAO,KAAK;EACtB,KAAK,OAAO,OAAO,MAAM;EACzB,MAAM,KAAK,OAAO,QAAQ;EAC1B,IAAI,MAAM,OAAO,MAAM;EACvB,SAAS,KAAK,OAAO,QAAQ;EAC9B;CACD,OAAO;EACL,IAAI,OAAO;EACX,KAAK,OAAO;EACZ,MAAM,OAAO;EACb,IAAI,OAAO;EACX,SAAS,OAAO;EACjB;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Logger, LoggerConfigItem, LoggerFormat } from '@verdaccio/types';
|
|
2
|
+
export type LogPlugin = {
|
|
3
|
+
dest: string;
|
|
4
|
+
options?: any[];
|
|
5
|
+
};
|
|
6
|
+
export declare function createLogger(options: LoggerConfigItem | undefined, destination: NodeJS.WritableStream | undefined, format: LoggerFormat | undefined, pino: any): any;
|
|
7
|
+
export type LoggerConfig = LoggerConfigItem;
|
|
8
|
+
export declare function willUseTransport(format: LoggerFormat | undefined): boolean;
|
|
9
|
+
export declare function prepareSetup(options: LoggerConfigItem | undefined, pino: any): Promise<Logger>;
|
package/build/logger.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
const require_formatter = require("./formatter.js");
|
|
3
|
+
const require_transport = require("./transport.js");
|
|
4
|
+
let debug = require("debug");
|
|
5
|
+
debug = require_runtime.__toESM(debug);
|
|
6
|
+
//#region src/logger.ts
|
|
7
|
+
var debug$1 = (0, debug.default)("verdaccio:logger");
|
|
8
|
+
function isProd() {
|
|
9
|
+
return process.env.NODE_ENV === "production";
|
|
10
|
+
}
|
|
11
|
+
var DEFAULT_LOG_FORMAT = isProd() ? "json" : "pretty";
|
|
12
|
+
debug$1("default log format: %s", DEFAULT_LOG_FORMAT);
|
|
13
|
+
function createLogger(options = { level: "http" }, destination, format = DEFAULT_LOG_FORMAT, pino) {
|
|
14
|
+
debug$1("setup logger");
|
|
15
|
+
let pinoConfig = {
|
|
16
|
+
customLevels: { http: 25 },
|
|
17
|
+
level: options.level,
|
|
18
|
+
serializers: {
|
|
19
|
+
err: pino.stdSerializers.err,
|
|
20
|
+
req: pino.stdSerializers.req,
|
|
21
|
+
res: pino.stdSerializers.res
|
|
22
|
+
},
|
|
23
|
+
redact: options.redact
|
|
24
|
+
};
|
|
25
|
+
debug$1("has prettifier? %o", !isProd());
|
|
26
|
+
let logger;
|
|
27
|
+
if (require_transport.isPrettyFormat(format) && isProd() === false) {
|
|
28
|
+
const transport = require_transport.createPrettyTransport(pino, options, format);
|
|
29
|
+
logger = pino(pinoConfig, transport);
|
|
30
|
+
} else {
|
|
31
|
+
pinoConfig = {
|
|
32
|
+
...pinoConfig,
|
|
33
|
+
hooks: { logMethod(args, method, _level) {
|
|
34
|
+
const [templateObject, message, ...otherArgs] = args;
|
|
35
|
+
if (!message || !(!!templateObject && typeof templateObject === "object" ? Object.getOwnPropertyNames(templateObject) : []).length) return method.apply(this, args);
|
|
36
|
+
const hydratedMessage = require_formatter.fillInMsgTemplate(message, templateObject, false);
|
|
37
|
+
return method.apply(this, [
|
|
38
|
+
templateObject,
|
|
39
|
+
hydratedMessage,
|
|
40
|
+
...otherArgs
|
|
41
|
+
]);
|
|
42
|
+
} }
|
|
43
|
+
};
|
|
44
|
+
logger = pino(pinoConfig, destination);
|
|
45
|
+
}
|
|
46
|
+
if (process.env.DEBUG) logger.on("level-change", (lvl, val, prevLvl, prevVal, instance) => {
|
|
47
|
+
if (logger !== instance) return;
|
|
48
|
+
debug$1("%s (%d) was changed to %s (%d)", lvl, val, prevLvl, prevVal);
|
|
49
|
+
});
|
|
50
|
+
return logger;
|
|
51
|
+
}
|
|
52
|
+
var DEFAULT_LOGGER_CONF = {
|
|
53
|
+
type: "stdout",
|
|
54
|
+
format: "pretty",
|
|
55
|
+
level: "http"
|
|
56
|
+
};
|
|
57
|
+
function willUseTransport(format) {
|
|
58
|
+
return require_transport.isPrettyFormat(format ?? (isProd() ? "json" : "pretty")) && isProd() === false;
|
|
59
|
+
}
|
|
60
|
+
async function prepareSetup(options = DEFAULT_LOGGER_CONF, pino) {
|
|
61
|
+
let loggerConfig = options;
|
|
62
|
+
if (!loggerConfig?.level) loggerConfig = {
|
|
63
|
+
...loggerConfig,
|
|
64
|
+
level: "http"
|
|
65
|
+
};
|
|
66
|
+
if (loggerConfig.type === "file") {
|
|
67
|
+
debug$1("logging file enabled");
|
|
68
|
+
if (willUseTransport(loggerConfig.format)) return createLogger(loggerConfig, void 0, loggerConfig.format, pino);
|
|
69
|
+
const destination = pino.destination(loggerConfig.path);
|
|
70
|
+
await new Promise((resolve, reject) => {
|
|
71
|
+
destination.once("ready", resolve);
|
|
72
|
+
destination.once("error", reject);
|
|
73
|
+
});
|
|
74
|
+
debug$1("file destination ready: %s", loggerConfig.path);
|
|
75
|
+
process.on("SIGUSR2", () => destination.reopen());
|
|
76
|
+
return createLogger(loggerConfig, destination, loggerConfig.format, pino);
|
|
77
|
+
}
|
|
78
|
+
debug$1("logging stdout enabled");
|
|
79
|
+
return createLogger(loggerConfig, pino.destination(1), loggerConfig.format, pino);
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
exports.createLogger = createLogger;
|
|
83
|
+
exports.prepareSetup = prepareSetup;
|
|
84
|
+
exports.willUseTransport = willUseTransport;
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","names":[],"sources":["../src/logger.ts"],"sourcesContent":["// <reference types=\"node\" />\nimport buildDebug from 'debug';\nimport type { LoggerOptions } from 'pino';\n\nimport type { Logger, LoggerConfigItem, LoggerFormat } from '@verdaccio/types';\n\nimport { fillInMsgTemplate } from './formatter';\nimport { createPrettyTransport, isPrettyFormat } from './transport';\n\nconst debug = buildDebug('verdaccio:logger');\n\nfunction isProd() {\n return process.env.NODE_ENV === 'production';\n}\n\nconst DEFAULT_LOG_FORMAT = isProd() ? 'json' : 'pretty';\ndebug('default log format: %s', DEFAULT_LOG_FORMAT);\n\nexport type LogPlugin = {\n dest: string;\n options?: any[];\n};\n\nexport function createLogger(\n options: LoggerConfigItem = { level: 'http' },\n destination: NodeJS.WritableStream | undefined,\n format: LoggerFormat = DEFAULT_LOG_FORMAT,\n pino\n): any {\n debug('setup logger');\n let pinoConfig: LoggerOptions = {\n customLevels: {\n http: 25,\n },\n level: options.level,\n serializers: {\n err: pino.stdSerializers.err,\n req: pino.stdSerializers.req,\n res: pino.stdSerializers.res,\n },\n redact: options.redact,\n };\n\n debug('has prettifier? %o', !isProd());\n let logger;\n // pretty logs are not allowed in production for performance reasons\n if (isPrettyFormat(format) && isProd() === false) {\n const transport = createPrettyTransport(pino, options, format);\n logger = pino(pinoConfig, transport);\n } else {\n pinoConfig = {\n ...pinoConfig,\n // https://getpino.io/#/docs/api?id=hooks-object\n hooks: {\n logMethod(args: [obj: unknown, msg?: string, ...rest: unknown[]], method, _level) {\n const [templateObject, message, ...otherArgs] = args;\n const templateVars =\n !!templateObject && typeof templateObject === 'object'\n ? Object.getOwnPropertyNames(templateObject)\n : [];\n if (!message || !templateVars.length) return method.apply(this, args);\n const hydratedMessage = fillInMsgTemplate(message, templateObject as any, false);\n return method.apply(this, [templateObject, hydratedMessage, ...otherArgs] as any);\n },\n },\n };\n logger = pino(pinoConfig, destination);\n }\n\n if (process.env.DEBUG) {\n logger.on('level-change', (lvl, val, prevLvl, prevVal, instance) => {\n if (logger !== instance) {\n return;\n }\n debug('%s (%d) was changed to %s (%d)', lvl, val, prevLvl, prevVal);\n });\n }\n\n return logger;\n}\n\nconst DEFAULT_LOGGER_CONF: LoggerConfigItem = {\n type: 'stdout',\n format: 'pretty',\n level: 'http',\n};\n\nexport type LoggerConfig = LoggerConfigItem;\n\nexport function willUseTransport(format: LoggerFormat | undefined): boolean {\n const resolvedFormat = format ?? (isProd() ? 'json' : 'pretty');\n return isPrettyFormat(resolvedFormat) && isProd() === false;\n}\n\nexport async function prepareSetup(\n options: LoggerConfigItem = DEFAULT_LOGGER_CONF,\n pino\n): Promise<Logger> {\n let loggerConfig = options;\n if (!loggerConfig?.level) {\n loggerConfig = {\n ...loggerConfig,\n level: 'http',\n };\n }\n if (loggerConfig.type === 'file') {\n debug('logging file enabled');\n // Pretty format uses a pino transport that creates its own destination stream,\n // so no destination is needed here.\n if (willUseTransport(loggerConfig.format)) {\n return createLogger(loggerConfig, undefined, loggerConfig.format, pino);\n }\n // For file destinations (json format), wait for the fd to be ready\n // so we fail fast on bad paths / permissions instead of losing early logs\n const destination = pino.destination(loggerConfig.path);\n await new Promise<void>((resolve, reject) => {\n destination.once('ready', resolve);\n destination.once('error', reject);\n });\n debug('file destination ready: %s', loggerConfig.path);\n process.on('SIGUSR2', () => destination.reopen());\n return createLogger(loggerConfig, destination, loggerConfig.format, pino);\n }\n debug('logging stdout enabled');\n return createLogger(loggerConfig, pino.destination(1), loggerConfig.format, pino);\n}\n"],"mappings":";;;;;;AASA,IAAM,WAAA,GAAA,MAAA,SAAmB,mBAAmB;AAE5C,SAAS,SAAS;AAChB,QAAA,QAAA,IAAA,aAAgC;;AAGlC,IAAM,qBAAqB,QAAQ,GAAG,SAAS;AAC/C,QAAM,0BAA0B,mBAAmB;AAOnD,SAAgB,aACd,UAA4B,EAAE,OAAO,QAAQ,EAC7C,aACA,SAAuB,oBACvB,MACK;AACL,SAAM,eAAe;CACrB,IAAI,aAA4B;EAC9B,cAAc,EACZ,MAAM,IACP;EACD,OAAO,QAAQ;EACf,aAAa;GACX,KAAK,KAAK,eAAe;GACzB,KAAK,KAAK,eAAe;GACzB,KAAK,KAAK,eAAe;GAC1B;EACD,QAAQ,QAAQ;EACjB;AAED,SAAM,sBAAsB,CAAC,QAAQ,CAAC;CACtC,IAAI;AAEJ,KAAI,kBAAA,eAAe,OAAO,IAAI,QAAQ,KAAK,OAAO;EAChD,MAAM,YAAY,kBAAA,sBAAsB,MAAM,SAAS,OAAO;AAC9D,WAAS,KAAK,YAAY,UAAU;QAC/B;AACL,eAAa;GACX,GAAG;GAEH,OAAO,EACL,UAAU,MAAwD,QAAQ,QAAQ;IAChF,MAAM,CAAC,gBAAgB,SAAS,GAAG,aAAa;AAKhD,QAAI,CAAC,WAAW,EAHd,CAAC,CAAC,kBAAkB,OAAO,mBAAmB,WAC1C,OAAO,oBAAoB,eAAe,GAC1C,EAAE,EACsB,OAAQ,QAAO,OAAO,MAAM,MAAM,KAAK;IACrE,MAAM,kBAAkB,kBAAA,kBAAkB,SAAS,gBAAuB,MAAM;AAChF,WAAO,OAAO,MAAM,MAAM;KAAC;KAAgB;KAAiB,GAAG;KAAU,CAAQ;MAEpF;GACF;AACD,WAAS,KAAK,YAAY,YAAY;;AAGxC,KAAI,QAAQ,IAAI,MACd,QAAO,GAAG,iBAAiB,KAAK,KAAK,SAAS,SAAS,aAAa;AAClE,MAAI,WAAW,SACb;AAEF,UAAM,kCAAkC,KAAK,KAAK,SAAS,QAAQ;GACnE;AAGJ,QAAO;;AAGT,IAAM,sBAAwC;CAC5C,MAAM;CACN,QAAQ;CACR,OAAO;CACR;AAID,SAAgB,iBAAiB,QAA2C;AAE1E,QAAO,kBAAA,eADgB,WAAW,QAAQ,GAAG,SAAS,UACjB,IAAI,QAAQ,KAAK;;AAGxD,eAAsB,aACpB,UAA4B,qBAC5B,MACiB;CACjB,IAAI,eAAe;AACnB,KAAI,CAAC,cAAc,MACjB,gBAAe;EACb,GAAG;EACH,OAAO;EACR;AAEH,KAAI,aAAa,SAAS,QAAQ;AAChC,UAAM,uBAAuB;AAG7B,MAAI,iBAAiB,aAAa,OAAO,CACvC,QAAO,aAAa,cAAc,KAAA,GAAW,aAAa,QAAQ,KAAK;EAIzE,MAAM,cAAc,KAAK,YAAY,aAAa,KAAK;AACvD,QAAM,IAAI,SAAe,SAAS,WAAW;AAC3C,eAAY,KAAK,SAAS,QAAQ;AAClC,eAAY,KAAK,SAAS,OAAO;IACjC;AACF,UAAM,8BAA8B,aAAa,KAAK;AACtD,UAAQ,GAAG,iBAAiB,YAAY,QAAQ,CAAC;AACjD,SAAO,aAAa,cAAc,aAAa,aAAa,QAAQ,KAAK;;AAE3E,SAAM,yBAAyB;AAC/B,QAAO,aAAa,cAAc,KAAK,YAAY,EAAE,EAAE,aAAa,QAAQ,KAAK"}
|