@webiny/logger 0.0.0-unstable.2696f9d9e8
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/LICENSE +21 -0
- package/README.md +15 -0
- package/index.d.ts +71 -0
- package/index.js +61 -0
- package/index.js.map +1 -0
- package/package.json +38 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Webiny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @webiny/logger
|
|
2
|
+
[](https://www.npmjs.com/package/@webiny/logger)
|
|
3
|
+
[](https://www.npmjs.com/package/@webiny/logger)
|
|
4
|
+
[](https://github.com/prettier/prettier)
|
|
5
|
+
[](http://makeapullrequest.com)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
```
|
|
9
|
+
npm install --save @webiny/logger
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Or if you prefer yarn:
|
|
13
|
+
```
|
|
14
|
+
yarn add @webiny/logger
|
|
15
|
+
```
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { DestinationStream, LevelWithSilent, Logger, LoggerOptions as BaseLoggerOptions, pino } from "pino";
|
|
2
|
+
export * from "pino";
|
|
3
|
+
export interface RedactOptions {
|
|
4
|
+
paths: string[];
|
|
5
|
+
censor?: string | ((value: any, path: string[]) => any);
|
|
6
|
+
remove?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface LoggerOptions extends Omit<BaseLoggerOptions, "redact"> {
|
|
9
|
+
redact?: string[] | RedactOptions;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Gets the log level from the input or the LOG_LEVEL environment variable.
|
|
13
|
+
*/
|
|
14
|
+
export declare const getLogLevel: (input?: string, defaultLevel?: LevelWithSilent) => string;
|
|
15
|
+
export declare const createPinoLogger: (input?: LoggerOptions, stream?: DestinationStream) => Logger<{
|
|
16
|
+
level: string;
|
|
17
|
+
redact?: string[] | RedactOptions | undefined;
|
|
18
|
+
transport?: pino.TransportSingleOptions<Record<string, any>> | pino.TransportMultiOptions<Record<string, any>> | pino.TransportPipelineOptions<Record<string, any>> | undefined;
|
|
19
|
+
name?: string | undefined;
|
|
20
|
+
base?: {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
} | null | undefined;
|
|
23
|
+
browser?: {
|
|
24
|
+
asObject?: boolean | undefined;
|
|
25
|
+
write?: pino.WriteFn | ({
|
|
26
|
+
fatal?: pino.WriteFn | undefined;
|
|
27
|
+
error?: pino.WriteFn | undefined;
|
|
28
|
+
warn?: pino.WriteFn | undefined;
|
|
29
|
+
info?: pino.WriteFn | undefined;
|
|
30
|
+
debug?: pino.WriteFn | undefined;
|
|
31
|
+
trace?: pino.WriteFn | undefined;
|
|
32
|
+
} & {
|
|
33
|
+
[logLevel: string]: pino.WriteFn;
|
|
34
|
+
}) | undefined;
|
|
35
|
+
serialize?: boolean | string[] | undefined;
|
|
36
|
+
transmit?: {
|
|
37
|
+
level?: string | undefined;
|
|
38
|
+
send: (level: pino.Level, logEvent: pino.LogEvent) => void;
|
|
39
|
+
} | undefined;
|
|
40
|
+
} | undefined;
|
|
41
|
+
customLevels?: {
|
|
42
|
+
[key: string]: number;
|
|
43
|
+
} | undefined;
|
|
44
|
+
useOnlyCustomLevels?: boolean | undefined;
|
|
45
|
+
levelVal?: number | undefined;
|
|
46
|
+
onChild?: (<ChildOptions extends pino.ChildLoggerOptions>(child: pino.Logger<BaseLoggerOptions & ChildOptions>) => void) | undefined;
|
|
47
|
+
safe?: boolean | undefined;
|
|
48
|
+
serializers?: {
|
|
49
|
+
[key: string]: pino.SerializerFn;
|
|
50
|
+
} | undefined;
|
|
51
|
+
timestamp?: boolean | (() => string) | undefined;
|
|
52
|
+
mixin?: ((mergeObject: object, level: number) => object) | undefined;
|
|
53
|
+
mixinMergeStrategy?: ((mergeObject: object, mixinObject: object) => object) | undefined;
|
|
54
|
+
messageKey?: string | undefined;
|
|
55
|
+
errorKey?: string | undefined;
|
|
56
|
+
nestedKey?: string | undefined;
|
|
57
|
+
enabled?: boolean | undefined;
|
|
58
|
+
formatters?: {
|
|
59
|
+
level?: ((label: string, number: number) => object) | undefined;
|
|
60
|
+
bindings?: ((bindings: pino.Bindings) => object) | undefined;
|
|
61
|
+
log?: ((object: Record<string, unknown>) => Record<string, unknown>) | undefined;
|
|
62
|
+
} | undefined;
|
|
63
|
+
msgPrefix?: string | undefined;
|
|
64
|
+
hooks?: {
|
|
65
|
+
logMethod?: ((this: pino.Logger<pino.LoggerOptions>, args: [msg: string, ...args: any[]], method: pino.LogFn, level: number) => void) | undefined;
|
|
66
|
+
} | undefined;
|
|
67
|
+
depthLimit?: number | undefined;
|
|
68
|
+
edgeLimit?: number | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
export declare const configureLogger: (options: LoggerOptions, stream?: DestinationStream) => void;
|
|
71
|
+
export declare const getLogger: () => Logger<BaseLoggerOptions>;
|
package/index.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
getLogLevel: true,
|
|
8
|
+
createPinoLogger: true,
|
|
9
|
+
configureLogger: true,
|
|
10
|
+
getLogger: true
|
|
11
|
+
};
|
|
12
|
+
exports.getLogger = exports.getLogLevel = exports.createPinoLogger = exports.configureLogger = void 0;
|
|
13
|
+
var _pino = require("pino");
|
|
14
|
+
Object.keys(_pino).forEach(function (key) {
|
|
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;
|
|
35
|
+
};
|
|
36
|
+
exports.getLogLevel = getLogLevel;
|
|
37
|
+
let logger;
|
|
38
|
+
const createPinoLogger = (input, stream) => {
|
|
39
|
+
const options = {
|
|
40
|
+
...(input || {}),
|
|
41
|
+
level: getLogLevel(input?.level)
|
|
42
|
+
};
|
|
43
|
+
if (!stream) {
|
|
44
|
+
return (0, _pino.pino)(options);
|
|
45
|
+
}
|
|
46
|
+
return (0, _pino.pino)(options, stream);
|
|
47
|
+
};
|
|
48
|
+
exports.createPinoLogger = createPinoLogger;
|
|
49
|
+
const configureLogger = (options, stream) => {
|
|
50
|
+
logger = createPinoLogger(options, stream);
|
|
51
|
+
};
|
|
52
|
+
exports.configureLogger = configureLogger;
|
|
53
|
+
const getLogger = () => {
|
|
54
|
+
if (!logger) {
|
|
55
|
+
logger = createPinoLogger();
|
|
56
|
+
}
|
|
57
|
+
return logger;
|
|
58
|
+
};
|
|
59
|
+
exports.getLogger = getLogger;
|
|
60
|
+
|
|
61
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_pino","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","levels","getLogLevel","input","defaultLevel","process","env","LOG_LEVEL","length","includes","logger","createPinoLogger","stream","options","level","pino","configureLogger","getLogger"],"sources":["index.ts"],"sourcesContent":["import {\n DestinationStream,\n LevelWithSilent,\n Logger,\n LoggerOptions as BaseLoggerOptions,\n pino\n} from \"pino\";\n\nexport * from \"pino\";\n\nexport interface RedactOptions {\n paths: string[];\n censor?: string | ((value: any, path: string[]) => any);\n remove?: boolean;\n}\n\nexport 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) => {\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"],"mappings":";;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAQAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AAYA,MAAMS,MAAyB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC;AAChG;AACA;AACA;AACO,MAAMC,WAAW,GAAGA,CAACC,KAAc,EAAEC,YAA6B,GAAG,MAAM,KAAa;EAC3FD,KAAK,GAAGA,KAAK,IAAIE,OAAO,CAACC,GAAG,CAACC,SAAS;EACtC,IAAI,CAACJ,KAAK,IAAIA,KAAK,CAACK,MAAM,KAAK,CAAC,EAAE;IAC9B,OAAOJ,YAAY;EACvB;EACA,OAAOH,MAAM,CAACQ,QAAQ,CAACN,KAAwB,CAAC,GAAGA,KAAK,GAAGC,YAAY;AAC3E,CAAC;AAACP,OAAA,CAAAK,WAAA,GAAAA,WAAA;AAEF,IAAIQ,MAAc;AAEX,MAAMC,gBAAgB,GAAGA,CAACR,KAAqB,EAAES,MAA0B,KAAK;EACnF,MAAMC,OAAO,GAAG;IACZ,IAAIV,KAAK,IAAI,CAAC,CAAC,CAAC;IAChBW,KAAK,EAAEZ,WAAW,CAACC,KAAK,EAAEW,KAAK;EACnC,CAAC;EACD,IAAI,CAACF,MAAM,EAAE;IACT,OAAO,IAAAG,UAAI,EAACF,OAAO,CAAC;EACxB;EACA,OAAO,IAAAE,UAAI,EAACF,OAAO,EAAED,MAAM,CAAC;AAChC,CAAC;AAACf,OAAA,CAAAc,gBAAA,GAAAA,gBAAA;AAEK,MAAMK,eAAe,GAAGA,CAACH,OAAsB,EAAED,MAA0B,KAAW;EACzFF,MAAM,GAAGC,gBAAgB,CAACE,OAAO,EAAED,MAAM,CAAC;AAC9C,CAAC;AAACf,OAAA,CAAAmB,eAAA,GAAAA,eAAA;AAEK,MAAMC,SAAS,GAAGA,CAAA,KAAM;EAC3B,IAAI,CAACP,MAAM,EAAE;IACTA,MAAM,GAAGC,gBAAgB,CAAC,CAAC;EAC/B;EACA,OAAOD,MAAM;AACjB,CAAC;AAACb,OAAA,CAAAoB,SAAA,GAAAA,SAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@webiny/logger",
|
|
3
|
+
"version": "0.0.0-unstable.2696f9d9e8",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/webiny/webiny-js.git"
|
|
8
|
+
},
|
|
9
|
+
"description": "Core package for all of our API packages.",
|
|
10
|
+
"contributors": [
|
|
11
|
+
"Bruno Zorić <bruno@webiny.com>"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@babel/runtime": "7.22.6"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@babel/cli": "7.22.6",
|
|
19
|
+
"@babel/core": "7.22.8",
|
|
20
|
+
"@babel/preset-env": "7.22.7",
|
|
21
|
+
"@babel/preset-typescript": "7.22.5",
|
|
22
|
+
"@webiny/cli": "0.0.0-unstable.2696f9d9e8",
|
|
23
|
+
"@webiny/project-utils": "0.0.0-unstable.2696f9d9e8",
|
|
24
|
+
"pino": "8.11.0",
|
|
25
|
+
"rimraf": "3.0.2",
|
|
26
|
+
"ttypescript": "1.5.15",
|
|
27
|
+
"typescript": "4.7.4"
|
|
28
|
+
},
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public",
|
|
31
|
+
"directory": "dist"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "yarn webiny run build",
|
|
35
|
+
"watch": "yarn webiny run watch"
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "2696f9d9e84ad621e1412a05e1252b5ca9c245fb"
|
|
38
|
+
}
|