@webiny/logger 0.0.0-unstable.a4637c5ce6 β 0.0.0-unstable.a4f3e4ea8b
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/README.md +10 -14
- package/index.d.ts +3 -5
- package/index.js +27 -54
- package/index.js.map +1 -1
- package/package.json +15 -13
package/README.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
# @webiny/logger
|
|
2
|
-
|
|
3
|
-
[!
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Or if you prefer yarn:
|
|
13
|
-
```
|
|
14
|
-
yarn add @webiny/logger
|
|
15
|
-
```
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This package is part of the [Webiny](https://www.webiny.com) monorepo.
|
|
5
|
+
> Itβs **included in every Webiny project by default** and is not meant to be used as a standalone package.
|
|
6
|
+
|
|
7
|
+
π **Documentation:** [https://www.webiny.com/docs](https://www.webiny.com/docs)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
_This README file is automatically generated during the publish process._
|
package/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type { DestinationStream, LevelWithSilent, Logger, LoggerOptions
|
|
2
|
-
export
|
|
1
|
+
import type { DestinationStream, LevelWithSilent, Logger, LoggerOptions } from "pino";
|
|
2
|
+
export { pino, levels, version, stdSerializers, symbols, stdTimeFunctions, multistream, destination, transport } from "pino";
|
|
3
|
+
export type { DestinationStream, Logger, LogFn, WriteFn, BaseLogger, TransportTargetOptions, TransportSingleOptions, TransportPipelineOptions, TransportMultiOptions, TransportBaseOptions, TimeFn, StreamEntry, SerializerFn, SerializedResponse, SerializedRequest, SerializedError, Bindings, ChildLoggerOptions, CustomLevelLogger, LoggerOptions, DestinationStreamHasMetadata, DestinationStreamWithMetadata, Level, LevelChangeEventListener, LevelMapping, LevelOrString, LevelWithSilent, redactOptions, PlaceholderTypeMapping, PlaceholderSpecifier, ParseLogFnArgs, OnChildCallback, MultiStreamRes, MultiStreamOptions, MixinMergeStrategyFn, MixinFn, LoggerExtras, LogEvent, LogDescriptor, LevelWithSilentOrString } from "pino";
|
|
3
4
|
export interface RedactOptions {
|
|
4
5
|
paths: string[];
|
|
5
6
|
censor?: string | ((value: any, path: string[]) => any);
|
|
6
7
|
remove?: boolean;
|
|
7
8
|
}
|
|
8
|
-
export interface LoggerOptions extends Omit<BaseLoggerOptions, "redact"> {
|
|
9
|
-
redact?: string[] | RedactOptions;
|
|
10
|
-
}
|
|
11
9
|
/**
|
|
12
10
|
* Gets the log level from the input or the LOG_LEVEL environment variable.
|
|
13
11
|
*/
|
package/index.js
CHANGED
|
@@ -1,61 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (key === "default" || key === "__esModule") return;
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
17
|
-
if (key in exports && exports[key] === _pino[key]) return;
|
|
18
|
-
Object.defineProperty(exports, key, {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () {
|
|
21
|
-
return _pino[key];
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
const levels = ["fatal", "error", "warn", "info", "debug", "trace", "silent"];
|
|
26
|
-
/**
|
|
27
|
-
* Gets the log level from the input or the LOG_LEVEL environment variable.
|
|
28
|
-
*/
|
|
29
|
-
const getLogLevel = (input, defaultLevel = "info") => {
|
|
30
|
-
input = input || process.env.LOG_LEVEL;
|
|
31
|
-
if (!input || input.length === 0) {
|
|
32
|
-
return defaultLevel;
|
|
33
|
-
}
|
|
34
|
-
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;
|
|
35
15
|
};
|
|
36
|
-
exports.getLogLevel = getLogLevel;
|
|
37
16
|
let logger;
|
|
38
|
-
const createPinoLogger = (input, stream)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
}
|
|
46
|
-
return (0, _pino.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);
|
|
47
24
|
};
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
logger = createPinoLogger(options, stream);
|
|
25
|
+
const configureLogger = (options, stream)=>{
|
|
26
|
+
logger = createPinoLogger(options, stream);
|
|
51
27
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
logger = createPinoLogger();
|
|
56
|
-
}
|
|
57
|
-
return logger;
|
|
28
|
+
const getLogger = ()=>{
|
|
29
|
+
if (!logger) logger = createPinoLogger();
|
|
30
|
+
return logger;
|
|
58
31
|
};
|
|
59
|
-
|
|
32
|
+
export { configureLogger, createPinoLogger, destination, getLogLevel, getLogger, levels, multistream, pino, stdSerializers, stdTimeFunctions, symbols, transport, version };
|
|
60
33
|
|
|
61
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,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/logger",
|
|
3
|
-
"version": "0.0.0-unstable.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.0.0-unstable.a4f3e4ea8b",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": "./index.js",
|
|
7
|
+
"./*": "./*"
|
|
8
|
+
},
|
|
5
9
|
"repository": {
|
|
6
10
|
"type": "git",
|
|
7
11
|
"url": "https://github.com/webiny/webiny-js.git"
|
|
@@ -12,18 +16,16 @@
|
|
|
12
16
|
],
|
|
13
17
|
"license": "MIT",
|
|
14
18
|
"devDependencies": {
|
|
15
|
-
"@webiny/
|
|
16
|
-
"pino": "
|
|
17
|
-
"rimraf": "6.
|
|
18
|
-
"typescript": "
|
|
19
|
+
"@webiny/build-tools": "0.0.0-unstable.a4f3e4ea8b",
|
|
20
|
+
"pino": "10.3.1",
|
|
21
|
+
"rimraf": "6.1.3",
|
|
22
|
+
"typescript": "7.0.2"
|
|
19
23
|
},
|
|
20
24
|
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
"directory": "dist"
|
|
23
|
-
},
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "node ../cli/bin.js run build",
|
|
26
|
-
"watch": "node ../cli/bin.js run watch"
|
|
25
|
+
"access": "public"
|
|
27
26
|
},
|
|
28
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
|
|
28
|
+
"webiny": {
|
|
29
|
+
"publishFrom": "dist"
|
|
30
|
+
}
|
|
29
31
|
}
|