@webiny/logger 6.3.0 → 6.4.0-beta.0
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/index.js +27 -32
- package/index.js.map +1 -1
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
import { pino } from "pino";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return defaultLevel;
|
|
15
|
-
}
|
|
16
|
-
return levels.includes(input) ? input : defaultLevel;
|
|
1
|
+
import { destination, levels, multistream, pino, stdSerializers, stdTimeFunctions, symbols, transport, version } from "pino";
|
|
2
|
+
const src_levels = [
|
|
3
|
+
"fatal",
|
|
4
|
+
"error",
|
|
5
|
+
"warn",
|
|
6
|
+
"info",
|
|
7
|
+
"debug",
|
|
8
|
+
"trace",
|
|
9
|
+
"silent"
|
|
10
|
+
];
|
|
11
|
+
const getLogLevel = (input, defaultLevel = "info")=>{
|
|
12
|
+
input = input || process.env.LOG_LEVEL;
|
|
13
|
+
if (!input || 0 === input.length) return defaultLevel;
|
|
14
|
+
return src_levels.includes(input) ? input : defaultLevel;
|
|
17
15
|
};
|
|
18
16
|
let logger;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return pino(options);
|
|
26
|
-
}
|
|
27
|
-
return pino(options, stream);
|
|
17
|
+
const createPinoLogger = (input, stream)=>{
|
|
18
|
+
const options = {
|
|
19
|
+
...input || {},
|
|
20
|
+
level: getLogLevel(input?.level)
|
|
21
|
+
};
|
|
22
|
+
if (!stream) return pino(options);
|
|
23
|
+
return pino(options, stream);
|
|
28
24
|
};
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
const configureLogger = (options, stream)=>{
|
|
26
|
+
logger = createPinoLogger(options, stream);
|
|
31
27
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
logger
|
|
35
|
-
}
|
|
36
|
-
return logger;
|
|
28
|
+
const getLogger = ()=>{
|
|
29
|
+
if (!logger) logger = createPinoLogger();
|
|
30
|
+
return logger;
|
|
37
31
|
};
|
|
32
|
+
export { configureLogger, createPinoLogger, destination, getLogLevel, getLogger, levels, multistream, pino, stdSerializers, stdTimeFunctions, symbols, transport, version };
|
|
38
33
|
|
|
39
34
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import type { DestinationStream, LevelWithSilent, Logger, LoggerOptions } from \"pino\";\nimport { pino } from \"pino\";\n\nexport {\n pino,\n levels,\n version,\n stdSerializers,\n symbols,\n stdTimeFunctions,\n multistream,\n destination,\n transport\n} from \"pino\";\nexport type {\n DestinationStream,\n Logger,\n LogFn,\n WriteFn,\n BaseLogger,\n TransportTargetOptions,\n TransportSingleOptions,\n TransportPipelineOptions,\n TransportMultiOptions,\n TransportBaseOptions,\n TimeFn,\n StreamEntry,\n SerializerFn,\n SerializedResponse,\n SerializedRequest,\n SerializedError,\n Bindings,\n ChildLoggerOptions,\n CustomLevelLogger,\n LoggerOptions,\n DestinationStreamHasMetadata,\n DestinationStreamWithMetadata,\n Level,\n LevelChangeEventListener,\n LevelMapping,\n LevelOrString,\n LevelWithSilent,\n redactOptions,\n PlaceholderTypeMapping,\n PlaceholderSpecifier,\n ParseLogFnArgs,\n OnChildCallback,\n MultiStreamRes,\n MultiStreamOptions,\n MixinMergeStrategyFn,\n MixinFn,\n LoggerExtras,\n LogEvent,\n LogDescriptor,\n LevelWithSilentOrString\n} from \"pino\";\n\nexport interface RedactOptions {\n paths: string[];\n censor?: string | ((value: any, path: string[]) => any);\n remove?: boolean;\n}\n\n// export interface LoggerOptions extends Omit<BaseLoggerOptions, \"redact\"> {\n// redact?: string[] | RedactOptions;\n// }\n\nconst levels: LevelWithSilent[] = [\"fatal\", \"error\", \"warn\", \"info\", \"debug\", \"trace\", \"silent\"];\n/**\n * Gets the log level from the input or the LOG_LEVEL environment variable.\n */\nexport const getLogLevel = (input?: string, defaultLevel: LevelWithSilent = \"info\"): string => {\n input = input || process.env.LOG_LEVEL;\n if (!input || input.length === 0) {\n return defaultLevel;\n }\n return levels.includes(input as LevelWithSilent) ? input : defaultLevel;\n};\n\nlet logger: Logger;\n\nexport const createPinoLogger = (input?: LoggerOptions, stream?: DestinationStream): Logger => {\n const options = {\n ...(input || {}),\n level: getLogLevel(input?.level)\n };\n if (!stream) {\n return pino(options);\n }\n return pino(options, stream);\n};\n\nexport const configureLogger = (options: LoggerOptions, stream?: DestinationStream): void => {\n logger = createPinoLogger(options, stream);\n};\n\nexport const getLogger = () => {\n if (!logger) {\n logger = createPinoLogger();\n }\n return logger;\n};\n"],"names":["levels","getLogLevel","input","defaultLevel","process","logger","createPinoLogger","stream","options","pino","configureLogger","getLogger"],"mappings":";AAmEA,MAAMA,aAA4B;IAAC;IAAS;IAAS;IAAQ;IAAQ;IAAS;IAAS;CAAS;AAIzF,MAAMC,cAAc,CAACC,OAAgBC,eAAgC,MAAM;IAC9ED,QAAQA,SAASE,QAAQ,GAAG,CAAC,SAAS;IACtC,IAAI,CAACF,SAASA,AAAiB,MAAjBA,MAAM,MAAM,EACtB,OAAOC;IAEX,OAAOH,WAAO,QAAQ,CAACE,SAA4BA,QAAQC;AAC/D;AAEA,IAAIE;AAEG,MAAMC,mBAAmB,CAACJ,OAAuBK;IACpD,MAAMC,UAAU;QACZ,GAAIN,SAAS,CAAC,CAAC;QACf,OAAOD,YAAYC,OAAO;IAC9B;IACA,IAAI,CAACK,QACD,OAAOE,KAAKD;IAEhB,OAAOC,KAAKD,SAASD;AACzB;AAEO,MAAMG,kBAAkB,CAACF,SAAwBD;IACpDF,SAASC,iBAAiBE,SAASD;AACvC;AAEO,MAAMI,YAAY;IACrB,IAAI,CAACN,QACDA,SAASC;IAEb,OAAOD;AACX"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/logger",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
],
|
|
17
17
|
"license": "MIT",
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@webiny/build-tools": "6.
|
|
19
|
+
"@webiny/build-tools": "6.4.0-beta.0",
|
|
20
20
|
"pino": "10.3.1",
|
|
21
21
|
"rimraf": "6.1.3",
|
|
22
22
|
"typescript": "6.0.3"
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"access": "public",
|
|
26
26
|
"directory": "dist"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "a545d7529828af07d08d49c3da1bcb967483b9ce"
|
|
29
29
|
}
|