xcally-nest-library 0.0.15 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +4 -71
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/src/modules/logger/pino/logger.default.d.ts +1 -0
- package/dist/src/modules/logger/pino/logger.default.js +6 -0
- package/dist/src/modules/logger/pino/logger.default.js.map +1 -0
- package/dist/src/modules/logger/pino/logger.module.d.ts +2 -0
- package/dist/src/modules/logger/pino/logger.module.js +51 -21
- package/dist/src/modules/logger/pino/logger.module.js.map +1 -1
- package/dist/src/modules/logger/pino/logger.service.d.ts +6 -11
- package/dist/src/modules/logger/pino/logger.service.js +15 -27
- package/dist/src/modules/logger/pino/logger.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/index.ts +1 -0
- package/package.json +2 -1
- package/src/modules/logger/pino/logger.default.ts +1 -0
- package/src/modules/logger/pino/logger.module.ts +72 -21
- package/src/modules/logger/pino/logger.service.ts +17 -32
package/README.md
CHANGED
@@ -1,73 +1,6 @@
|
|
1
|
-
|
2
|
-
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
3
|
-
</p>
|
1
|
+
# Publish library
|
4
2
|
|
5
|
-
|
6
|
-
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
3
|
+
## Patch
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
11
|
-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
12
|
-
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
13
|
-
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
14
|
-
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
15
|
-
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
16
|
-
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
17
|
-
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
18
|
-
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
19
|
-
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
20
|
-
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
21
|
-
</p>
|
22
|
-
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
|
23
|
-
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
|
24
|
-
|
25
|
-
## Description
|
26
|
-
|
27
|
-
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
28
|
-
|
29
|
-
## Installation
|
30
|
-
|
31
|
-
```bash
|
32
|
-
$ pnpm install
|
33
|
-
```
|
34
|
-
|
35
|
-
## Running the app
|
36
|
-
|
37
|
-
```bash
|
38
|
-
# development
|
39
|
-
$ pnpm run start
|
40
|
-
|
41
|
-
# watch mode
|
42
|
-
$ pnpm run start:dev
|
43
|
-
|
44
|
-
# production mode
|
45
|
-
$ pnpm run start:prod
|
46
|
-
```
|
47
|
-
|
48
|
-
## Test
|
49
|
-
|
50
|
-
```bash
|
51
|
-
# unit tests
|
52
|
-
$ pnpm run test
|
53
|
-
|
54
|
-
# e2e tests
|
55
|
-
$ pnpm run test:e2e
|
56
|
-
|
57
|
-
# test coverage
|
58
|
-
$ pnpm run test:cov
|
59
|
-
```
|
60
|
-
|
61
|
-
## Support
|
62
|
-
|
63
|
-
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
64
|
-
|
65
|
-
## Stay in touch
|
66
|
-
|
67
|
-
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
68
|
-
- Website - [https://nestjs.com](https://nestjs.com/)
|
69
|
-
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
70
|
-
|
71
|
-
## License
|
72
|
-
|
73
|
-
Nest is [MIT licensed](LICENSE).
|
5
|
+
Run `pnpm bump:patch`
|
6
|
+
Run `npm publish`. It doesn't work with pnpm
|
package/dist/index.d.ts
CHANGED
@@ -9,3 +9,4 @@ export * from './src/decorators/utils.decorators';
|
|
9
9
|
export * from './src/config/env.validation';
|
10
10
|
export * from './src/modules/logger/pino/logger.service';
|
11
11
|
export * from './src/modules/logger/pino/logger.module';
|
12
|
+
export * from './src/modules/logger/pino/logger.default';
|
package/dist/index.js
CHANGED
@@ -25,4 +25,5 @@ __exportStar(require("./src/decorators/utils.decorators"), exports);
|
|
25
25
|
__exportStar(require("./src/config/env.validation"), exports);
|
26
26
|
__exportStar(require("./src/modules/logger/pino/logger.service"), exports);
|
27
27
|
__exportStar(require("./src/modules/logger/pino/logger.module"), exports);
|
28
|
+
__exportStar(require("./src/modules/logger/pino/logger.default"), exports);
|
28
29
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6EAA2D;AAC3D,2EAAyD;AACzD,uEAAqD;AACrD,sEAAoD;AACpD,qEAAmD;AACnD,sEAAoD;AACpD,oEAAkD;AAClD,8DAA4C;AAC5C,2EAAyD;AACzD,0EAAwD"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,6EAA2D;AAC3D,2EAAyD;AACzD,uEAAqD;AACrD,sEAAoD;AACpD,qEAAmD;AACnD,sEAAoD;AACpD,oEAAkD;AAClD,8DAA4C;AAC5C,2EAAyD;AACzD,0EAAwD;AACxD,2EAAyD"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { Logger } from 'nestjs-pino';
|
@@ -0,0 +1,6 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.Logger = void 0;
|
4
|
+
var nestjs_pino_1 = require("nestjs-pino");
|
5
|
+
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return nestjs_pino_1.Logger; } });
|
6
|
+
//# sourceMappingURL=logger.default.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"logger.default.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.default.ts"],"names":[],"mappings":";;;AAAA,2CAAqC;AAA5B,qGAAA,MAAM,OAAA"}
|
@@ -5,32 +5,62 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
7
|
};
|
8
|
+
var LoggerModule_1;
|
8
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
9
10
|
exports.LoggerModule = void 0;
|
10
11
|
const common_1 = require("@nestjs/common");
|
11
|
-
const
|
12
|
+
const config_1 = require("@nestjs/config");
|
12
13
|
const nestjs_pino_1 = require("nestjs-pino");
|
13
|
-
const
|
14
|
-
let LoggerModule = class LoggerModule {
|
14
|
+
const logger_service_1 = require("./logger.service");
|
15
|
+
let LoggerModule = LoggerModule_1 = class LoggerModule {
|
16
|
+
static forRoot() {
|
17
|
+
return {
|
18
|
+
module: LoggerModule_1,
|
19
|
+
providers: [logger_service_1.LoggerService],
|
20
|
+
exports: [logger_service_1.LoggerService],
|
21
|
+
imports: [
|
22
|
+
nestjs_pino_1.LoggerModule.forRootAsync({
|
23
|
+
imports: [config_1.ConfigModule],
|
24
|
+
inject: [config_1.ConfigService],
|
25
|
+
useFactory: async (config) => {
|
26
|
+
const projectName = process.env.npm_package_name || 'default_project';
|
27
|
+
return {
|
28
|
+
pinoHttp: {
|
29
|
+
level: config.get('LOG_LEVEL') || 'info',
|
30
|
+
redact: {
|
31
|
+
paths: ['req.headers.cookie', 'req.headers.authorization'],
|
32
|
+
},
|
33
|
+
transport: {
|
34
|
+
targets: [
|
35
|
+
{
|
36
|
+
level: 'debug',
|
37
|
+
target: 'pino-pretty',
|
38
|
+
options: {
|
39
|
+
colorize: true,
|
40
|
+
},
|
41
|
+
},
|
42
|
+
{
|
43
|
+
level: 'info',
|
44
|
+
target: 'pino/file',
|
45
|
+
options: {
|
46
|
+
destination: `./logs/${projectName}-info.log`,
|
47
|
+
mkdir: true,
|
48
|
+
append: process.env.NODE_ENV !== 'production' ? false : true,
|
49
|
+
},
|
50
|
+
},
|
51
|
+
],
|
52
|
+
},
|
53
|
+
},
|
54
|
+
};
|
55
|
+
},
|
56
|
+
}),
|
57
|
+
],
|
58
|
+
};
|
59
|
+
}
|
15
60
|
};
|
16
61
|
exports.LoggerModule = LoggerModule;
|
17
|
-
exports.LoggerModule = LoggerModule = __decorate([
|
18
|
-
(0, common_1.
|
19
|
-
|
20
|
-
exports: [logger_service_1.LoggerService],
|
21
|
-
imports: [
|
22
|
-
nestjs_pino_1.LoggerModule.forRoot({
|
23
|
-
pinoHttp: {
|
24
|
-
genReqId: () => {
|
25
|
-
const activeSpan = api_1.default.trace.getSpan(api_1.default.context.active());
|
26
|
-
return activeSpan.spanContext().traceId;
|
27
|
-
},
|
28
|
-
redact: {
|
29
|
-
paths: ['req.headers.cookie', 'req.headers.authorization'],
|
30
|
-
},
|
31
|
-
},
|
32
|
-
}),
|
33
|
-
],
|
34
|
-
})
|
62
|
+
exports.LoggerModule = LoggerModule = LoggerModule_1 = __decorate([
|
63
|
+
(0, common_1.Global)(),
|
64
|
+
(0, common_1.Module)({})
|
35
65
|
], LoggerModule);
|
36
66
|
//# sourceMappingURL=logger.module.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.module.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"logger.module.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAC/D,2CAA6D;AAC7D,6CAA+D;AAC/D,qDAAiD;AAI1C,IAAM,YAAY,oBAAlB,MAAM,YAAY;IACvB,MAAM,CAAC,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,cAAY;YACpB,SAAS,EAAE,CAAC,8BAAa,CAAC;YAC1B,OAAO,EAAE,CAAC,8BAAa,CAAC;YACxB,OAAO,EAAE;gBACP,0BAAgB,CAAC,YAAY,CAAC;oBAC5B,OAAO,EAAE,CAAC,qBAAY,CAAC;oBACvB,MAAM,EAAE,CAAC,sBAAa,CAAC;oBACvB,UAAU,EAAE,KAAK,EAAE,MAAqB,EAAE,EAAE;wBAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,iBAAiB,CAAC;wBACtE,OAAO;4BACL,QAAQ,EAAE;gCACR,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,MAAM;gCAWxC,MAAM,EAAE;oCACN,KAAK,EAAE,CAAC,oBAAoB,EAAE,2BAA2B,CAAC;iCAC3D;gCACD,SAAS,EAAE;oCACT,OAAO,EAAE;wCACP;4CACE,KAAK,EAAE,OAAO;4CACd,MAAM,EAAE,aAAa;4CACrB,OAAO,EAAE;gDACP,QAAQ,EAAE,IAAI;6CACf;yCACF;wCAQD;4CACE,KAAK,EAAE,MAAM;4CACb,MAAM,EAAE,WAAW;4CACnB,OAAO,EAAE;gDACP,WAAW,EAAE,UAAU,WAAW,WAAW;gDAC7C,KAAK,EAAE,IAAI;gDACX,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;6CAC7D;yCACF;qCACF;iCACF;6BAKF;yBACF,CAAC;oBACJ,CAAC;iBACF,CAAC;aACH;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAlEY,oCAAY;uBAAZ,YAAY;IAFxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,YAAY,CAkExB"}
|
@@ -1,15 +1,10 @@
|
|
1
1
|
import { PinoLogger } from 'nestjs-pino';
|
2
|
-
|
3
|
-
type PinoMethods = Pick<pino.Logger, 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'>;
|
4
|
-
export declare class LoggerService implements PinoMethods {
|
2
|
+
export declare class LoggerService {
|
5
3
|
private readonly logger;
|
6
4
|
constructor(logger: PinoLogger);
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
info(msg: string, ...args: any[]): void;
|
13
|
-
log(msg: string, ...args: any[]): void;
|
5
|
+
debug(msg: string, meta?: any): void;
|
6
|
+
warn(msg: string, meta?: any): void;
|
7
|
+
error(msg: string, meta?: any): void;
|
8
|
+
fatal(msg: string, meta?: any): void;
|
9
|
+
info(msg: string, meta?: any): void;
|
14
10
|
}
|
15
|
-
export {};
|
@@ -17,42 +17,30 @@ let LoggerService = class LoggerService {
|
|
17
17
|
constructor(logger) {
|
18
18
|
this.logger = logger;
|
19
19
|
}
|
20
|
-
|
20
|
+
debug(msg, meta) {
|
21
21
|
const activeSpan = api_1.default.trace.getSpan(api_1.default.context.active());
|
22
|
-
activeSpan.addEvent(msg
|
23
|
-
this.logger.
|
22
|
+
activeSpan.addEvent(msg);
|
23
|
+
this.logger.debug({ meta }, msg);
|
24
24
|
}
|
25
|
-
|
25
|
+
warn(msg, meta) {
|
26
26
|
const activeSpan = api_1.default.trace.getSpan(api_1.default.context.active());
|
27
|
-
activeSpan.addEvent(msg
|
28
|
-
this.logger.
|
27
|
+
activeSpan.addEvent(msg);
|
28
|
+
this.logger.warn({ meta }, msg);
|
29
29
|
}
|
30
|
-
|
30
|
+
error(msg, meta) {
|
31
31
|
const activeSpan = api_1.default.trace.getSpan(api_1.default.context.active());
|
32
|
-
activeSpan.addEvent(msg
|
33
|
-
this.logger.
|
32
|
+
activeSpan.addEvent(msg);
|
33
|
+
this.logger.error({ meta }, msg);
|
34
34
|
}
|
35
|
-
|
35
|
+
fatal(msg, meta) {
|
36
36
|
const activeSpan = api_1.default.trace.getSpan(api_1.default.context.active());
|
37
|
-
activeSpan.addEvent(msg
|
38
|
-
this.logger.
|
37
|
+
activeSpan.addEvent(msg);
|
38
|
+
this.logger.fatal({ meta }, msg);
|
39
39
|
}
|
40
|
-
|
40
|
+
info(msg, meta) {
|
41
41
|
const activeSpan = api_1.default.trace.getSpan(api_1.default.context.active());
|
42
|
-
activeSpan.addEvent(msg
|
43
|
-
this.logger.
|
44
|
-
}
|
45
|
-
info(msg, ...args) {
|
46
|
-
const activeSpan = api_1.default.trace.getSpan(api_1.default.context.active());
|
47
|
-
activeSpan.addEvent(msg, ...args);
|
48
|
-
this.logger.info(msg, ...args);
|
49
|
-
}
|
50
|
-
log(msg, ...args) {
|
51
|
-
const activeSpan = api_1.default.trace.getSpan(api_1.default.context.active());
|
52
|
-
if (activeSpan) {
|
53
|
-
activeSpan.addEvent(msg, ...args);
|
54
|
-
}
|
55
|
-
this.logger.info(msg, ...args);
|
42
|
+
activeSpan.addEvent(msg);
|
43
|
+
this.logger.info({ meta }, msg);
|
56
44
|
}
|
57
45
|
};
|
58
46
|
exports.LoggerService = LoggerService;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"logger.service.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAyC;
|
1
|
+
{"version":3,"file":"logger.service.js","sourceRoot":"","sources":["../../../../../src/modules/logger/pino/logger.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,6CAAyC;AACzC,4CAAqC;AAG9B,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAA6B,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAEnD,KAAK,CAAC,GAAW,EAAE,IAAU;QAC3B,MAAM,UAAU,GAAG,aAAG,CAAC,KAAK,CAAC,OAAO,CAAC,aAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3D,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;IACD,IAAI,CAAC,GAAW,EAAE,IAAU;QAC1B,MAAM,UAAU,GAAG,aAAG,CAAC,KAAK,CAAC,OAAO,CAAC,aAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3D,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IACD,KAAK,CAAC,GAAW,EAAE,IAAU;QAC3B,MAAM,UAAU,GAAG,aAAG,CAAC,KAAK,CAAC,OAAO,CAAC,aAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3D,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,CAAC,GAAW,EAAE,IAAU;QAC3B,MAAM,UAAU,GAAG,aAAG,CAAC,KAAK,CAAC,OAAO,CAAC,aAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3D,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,GAAW,EAAE,IAAU;QAE1B,MAAM,UAAU,GAAG,aAAG,CAAC,KAAK,CAAC,OAAO,CAAC,aAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAC3D,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QASzB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;CACF,CAAA;AAtCY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAE0B,wBAAU;GADpC,aAAa,CAsCzB"}
|