@adatechnology/logger 0.0.8 → 0.0.10
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 +2 -17
- package/agents/skills/SKILL.md +15 -5
- package/dist/index.d.ts +36 -8
- package/dist/index.js +272 -173
- package/package.json +1 -1
- package/src/context/async-context.service.ts +1 -1
- package/src/implementations/winston/winston.logger.module.ts +231 -176
- package/src/implementations/winston/winston.logger.provider.ts +47 -48
- package/src/index.ts +14 -2
- package/src/interceptors/exclude-http-logging.decorator.ts +6 -0
- package/src/interceptors/http-logging.interceptor.ts +40 -4
- package/src/logger.config.ts +6 -0
- package/src/logger.interface.ts +24 -8
- package/src/logger.module.ts +13 -4
- package/src/logger.provider.ts +19 -30
- package/src/logger.token.ts +1 -0
package/src/logger.interface.ts
CHANGED
|
@@ -5,21 +5,37 @@ export enum LoggerLevel {
|
|
|
5
5
|
ERROR = "error",
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export type LogParams = {
|
|
9
9
|
message: string;
|
|
10
10
|
context?: string;
|
|
11
11
|
meta?: Record<string, unknown>;
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type LogResult = void;
|
|
15
|
+
|
|
16
|
+
export type DebugParams = LogParams;
|
|
17
|
+
export type DebugResult = LogResult;
|
|
18
|
+
|
|
19
|
+
export type InfoParams = LogParams;
|
|
20
|
+
export type InfoResult = LogResult;
|
|
21
|
+
|
|
22
|
+
export type WarnParams = LogParams;
|
|
23
|
+
export type WarnResult = LogResult;
|
|
24
|
+
|
|
25
|
+
export type ErrorParams = LogParams;
|
|
26
|
+
export type ErrorResult = LogResult;
|
|
13
27
|
|
|
14
28
|
export interface LoggerProviderInterface {
|
|
15
|
-
debug(
|
|
16
|
-
info(
|
|
17
|
-
warn(
|
|
18
|
-
error(
|
|
29
|
+
debug(params: DebugParams): DebugResult;
|
|
30
|
+
info(params: InfoParams): InfoResult;
|
|
31
|
+
warn(params: WarnParams): WarnResult;
|
|
32
|
+
error(params: ErrorParams): ErrorResult;
|
|
19
33
|
setContext?(context: string): void;
|
|
20
34
|
}
|
|
21
35
|
|
|
22
|
-
export type
|
|
36
|
+
export type WriteLogParams = {
|
|
23
37
|
level: LoggerLevel;
|
|
24
|
-
payload:
|
|
38
|
+
payload: LogParams;
|
|
25
39
|
};
|
|
40
|
+
|
|
41
|
+
export type WriteLogResult = LogResult;
|
package/src/logger.module.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DynamicModule, Module, Scope, Provider, Global } from "@nestjs/common";
|
|
2
2
|
import { LoggerProvider } from "./logger.provider";
|
|
3
|
-
import { LOGGER_PROVIDER, HTTP_LOGGING_INTERCEPTOR } from "./logger.token";
|
|
3
|
+
import { LOGGER_PROVIDER, LOGGER_CONFIG, HTTP_LOGGING_INTERCEPTOR } from "./logger.token";
|
|
4
4
|
import { WinstonImplementationModule } from "./implementations/winston/winston.logger.module";
|
|
5
5
|
import { HttpLoggingInterceptor } from "./interceptors/http-logging.interceptor";
|
|
6
6
|
import type { LoggerConfig } from "./logger.config";
|
|
@@ -26,8 +26,12 @@ export class LoggerModule {
|
|
|
26
26
|
return {
|
|
27
27
|
module: LoggerModule,
|
|
28
28
|
imports: [implModule],
|
|
29
|
-
providers: [
|
|
30
|
-
|
|
29
|
+
providers: [
|
|
30
|
+
{ provide: LOGGER_CONFIG, useValue: config ?? {} },
|
|
31
|
+
loggerProvider,
|
|
32
|
+
httpLoggingInterceptorProvider,
|
|
33
|
+
],
|
|
34
|
+
exports: [LOGGER_PROVIDER, LOGGER_CONFIG, HTTP_LOGGING_INTERCEPTOR],
|
|
31
35
|
};
|
|
32
36
|
}
|
|
33
37
|
|
|
@@ -43,13 +47,18 @@ export class LoggerModule {
|
|
|
43
47
|
WinstonImplementationModule.forRootAsync(options),
|
|
44
48
|
],
|
|
45
49
|
providers: [
|
|
50
|
+
{
|
|
51
|
+
provide: LOGGER_CONFIG,
|
|
52
|
+
useFactory: options.useFactory,
|
|
53
|
+
inject: options.inject || [],
|
|
54
|
+
},
|
|
46
55
|
{
|
|
47
56
|
provide: LOGGER_PROVIDER,
|
|
48
57
|
useClass: LoggerProvider,
|
|
49
58
|
},
|
|
50
59
|
httpLoggingInterceptorProvider,
|
|
51
60
|
],
|
|
52
|
-
exports: [LOGGER_PROVIDER, HTTP_LOGGING_INTERCEPTOR],
|
|
61
|
+
exports: [LOGGER_PROVIDER, LOGGER_CONFIG, HTTP_LOGGING_INTERCEPTOR],
|
|
53
62
|
};
|
|
54
63
|
}
|
|
55
64
|
}
|
package/src/logger.provider.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { Injectable, Inject } from "@nestjs/common";
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
DebugParams,
|
|
4
|
+
DebugResult,
|
|
5
|
+
ErrorParams,
|
|
6
|
+
ErrorResult,
|
|
7
|
+
InfoParams,
|
|
8
|
+
InfoResult,
|
|
9
|
+
LoggerProviderInterface,
|
|
10
|
+
WarnParams,
|
|
11
|
+
WarnResult,
|
|
12
|
+
} from "./logger.interface";
|
|
3
13
|
import { WINSTON_LOGGER } from "./implementations/winston/winston.logger.token";
|
|
4
14
|
|
|
5
15
|
@Injectable()
|
|
@@ -9,45 +19,24 @@ export class LoggerProvider implements LoggerProviderInterface {
|
|
|
9
19
|
private readonly implementation: LoggerProviderInterface,
|
|
10
20
|
) {}
|
|
11
21
|
|
|
12
|
-
debug(
|
|
13
|
-
|
|
14
|
-
message: string,
|
|
15
|
-
meta?: Record<string, unknown>,
|
|
16
|
-
context?: string,
|
|
17
|
-
): void;
|
|
18
|
-
debug(...args: unknown[]): void {
|
|
19
|
-
// @ts-ignore - delegate to implementation which supports overloads
|
|
20
|
-
return this.implementation.debug(...(args as any));
|
|
22
|
+
debug(params: DebugParams): DebugResult {
|
|
23
|
+
return this.implementation.debug(params);
|
|
21
24
|
}
|
|
22
25
|
|
|
23
|
-
info(
|
|
24
|
-
|
|
25
|
-
info(...args: unknown[]): void {
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
return this.implementation.info(...(args as any));
|
|
26
|
+
info(params: InfoParams): InfoResult {
|
|
27
|
+
return this.implementation.info(params);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
warn(
|
|
31
|
-
|
|
32
|
-
warn(...args: unknown[]): void {
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
return this.implementation.warn(...(args as any));
|
|
30
|
+
warn(params: WarnParams): WarnResult {
|
|
31
|
+
return this.implementation.warn(params);
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
error(
|
|
38
|
-
|
|
39
|
-
message: string,
|
|
40
|
-
meta?: Record<string, unknown>,
|
|
41
|
-
context?: string,
|
|
42
|
-
): void;
|
|
43
|
-
error(...args: unknown[]): void {
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
return this.implementation.error(...(args as any));
|
|
34
|
+
error(params: ErrorParams): ErrorResult {
|
|
35
|
+
return this.implementation.error(params);
|
|
46
36
|
}
|
|
47
37
|
setContext?(context: string): void {
|
|
48
38
|
if (typeof this.implementation.setContext === "function") {
|
|
49
39
|
return this.implementation.setContext(context);
|
|
50
40
|
}
|
|
51
|
-
return;
|
|
52
41
|
}
|
|
53
42
|
}
|
package/src/logger.token.ts
CHANGED