File tree 2 files changed +39
-3
lines changed
2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change 1
- import { LoggerOptions } from './dist/index' ;
1
+ import { ITransport , LoggerOptions , TransportUnionOptions } from './dist/index' ;
2
2
3
3
export * from './dist/index' ;
4
4
5
+ type WithoutITransport < T > = {
6
+ [ P in keyof T ] : Exclude < T [ P ] , ITransport > ;
7
+ } ;
8
+
9
+ type NewTransportUnionOptions = WithoutITransport < TransportUnionOptions > ;
10
+
11
+ interface ConfigLoggerOptions extends LoggerOptions {
12
+ /**
13
+ * Output transport
14
+ */
15
+ transports ?: NewTransportUnionOptions ;
16
+ }
17
+
5
18
declare module '@midwayjs/core/dist/interface' {
6
19
// eslint-disable-next-line @typescript-eslint/no-empty-interface
7
- interface MidwayLoggerOptions extends LoggerOptions { }
20
+ interface MidwayLoggerOptions extends ConfigLoggerOptions { }
8
21
}
Original file line number Diff line number Diff line change @@ -23,6 +23,29 @@ export type LoggerInfo = {
23
23
originError ?: Error ;
24
24
} ;
25
25
26
+ export interface TransportUnionOptions {
27
+ /**
28
+ * console transport options
29
+ */
30
+ console ?: ConsoleTransportOptions | ITransport | false ;
31
+ /**
32
+ * file transport options
33
+ */
34
+ file ?: FileTransportOptions | ITransport | false ;
35
+ /**
36
+ * error transport options
37
+ */
38
+ error ?: FileTransportOptions | ITransport | false ;
39
+ /**
40
+ * json transport options
41
+ */
42
+ json ?: FileTransportOptions | ITransport | false ;
43
+ /**
44
+ * custom transport options
45
+ */
46
+ [ key : string ] : Record < string , any > | ITransport | false ;
47
+ }
48
+
26
49
export interface LoggerOptions {
27
50
/**
28
51
* default level for console,file and json logger
@@ -43,7 +66,7 @@ export interface LoggerOptions {
43
66
/**
44
67
* Output transport
45
68
*/
46
- transports ?: Record < string , ITransport | Record < string , any > | false > ;
69
+ transports ?: TransportUnionOptions ;
47
70
}
48
71
49
72
export interface ContextLoggerOptions {
You can’t perform that action at this time.
0 commit comments