1
1
import bunyan = require( "bunyan" ) ;
2
2
import { Application } from "express" ;
3
- import { Options as MorganOptions } from "morgan"
3
+ import { Options as MorganOptions } from "morgan" ;
4
+ import http = require( "http" ) ;
4
5
5
6
interface ILogFieldOptions {
6
- application_type ?: string ;
7
- log_type ?: string ;
8
- service ?: string ;
7
+ application_type ?: string ;
8
+ log_type ?: string ;
9
+ service ?: string ;
9
10
}
10
11
11
12
declare namespace ServiceLogger {
12
- export interface ILog4broOptions {
13
- productionMode ?: boolean ;
14
- logDir ?: string ;
15
- silence ?: boolean ;
16
- dockerMode ?: boolean ;
17
- varKey ?: string ;
18
- logFieldOptions ?: ILogFieldOptions ;
19
- level ?: string ;
20
- logLevel ?: string ;
21
- serviceName ?: string ;
22
- stackdriver ?: { scope : string } ;
23
- caller ?: string ;
24
- loggerName ?: string ;
25
- }
13
+ export interface ILog4broOptions {
14
+ productionMode ?: boolean ;
15
+ logDir ?: string ;
16
+ silence ?: boolean ;
17
+ dockerMode ?: boolean ;
18
+ varKey ?: string ;
19
+ logFieldOptions ?: ILogFieldOptions ;
20
+ level ?: string ;
21
+ logLevel ?: string ;
22
+ serviceName ?: string ;
23
+ stackdriver ?: { scope : string } ;
24
+ caller ?: string ;
25
+ loggerName ?: string ;
26
+ }
26
27
}
27
28
28
- declare class ServiceLogger {
29
- productionMode : boolean ;
30
- varKey : string ;
31
- dockerMode : boolean ;
32
- logFieldOptions : ILogFieldOptions ;
33
- silence : boolean ;
34
- logDir : string ;
35
- logLevel : string ;
36
- serviceName : string ;
37
- stackdriver : { scope : string } ;
38
- caller : string ;
39
- skipDebug : boolean ;
40
- LOG : bunyan ;
29
+ declare class ServiceLogger <
30
+ Request extends http . IncomingMessage ,
31
+ Response extends http . ServerResponse
32
+ > {
33
+ productionMode : boolean ;
34
+ varKey : string ;
35
+ dockerMode : boolean ;
36
+ logFieldOptions : ILogFieldOptions ;
37
+ silence : boolean ;
38
+ logDir : string ;
39
+ logLevel : string ;
40
+ serviceName : string ;
41
+ stackdriver : { scope : string } ;
42
+ caller : string ;
43
+ skipDebug : boolean ;
44
+ LOG : bunyan ;
41
45
42
- errors : any [ ] ;
46
+ errors : any [ ] ;
43
47
44
- constructor ( options : ServiceLogger . ILog4broOptions ) ;
45
- constructor ( loggerName : string ,
46
- silence : boolean ,
47
- logDir : string ,
48
- productionMode : boolean ,
49
- dockerMode : boolean ,
50
- varKey : string ,
51
- logFieldOptions : ILogFieldOptions ,
52
- level : string ,
53
- serviceName : string ,
54
- caller : string ,
55
- stackdriver : { scope : string } ,
56
- ) ;
48
+ constructor ( options : ServiceLogger . ILog4broOptions ) ;
49
+ constructor (
50
+ loggerName : string ,
51
+ silence : boolean ,
52
+ logDir : string ,
53
+ productionMode : boolean ,
54
+ dockerMode : boolean ,
55
+ varKey : string ,
56
+ logFieldOptions : ILogFieldOptions ,
57
+ level : string ,
58
+ serviceName : string ,
59
+ caller : string ,
60
+ stackdriver : { scope : string }
61
+ ) ;
57
62
58
- createChild ( defaultAdditionalFields ?: any ) : ServiceLogger ;
59
- changeLogLevel ( level : string ) : void ;
60
- createLoggingDir ( ) : void ;
61
- applyMiddlewareAccessLog ( expressApp : Application , customTokens ?: any , accessLogOptions ?: MorganOptions ) : Application ;
62
- applyMiddlewareAccessLogFile ( expressApp : Application , logFilePath : string ) : Application ;
63
- setGlobal ( ) : void ;
63
+ createChild ( defaultAdditionalFields ?: any ) : ServiceLogger < Request , Response > ;
64
+ changeLogLevel ( level : string ) : void ;
65
+ createLoggingDir ( ) : void ;
66
+ applyMiddlewareAccessLog (
67
+ expressApp : Application ,
68
+ customTokens ?: any ,
69
+ accessLogOptions ?: MorganOptions < Request , Response >
70
+ ) : Application ;
71
+ applyMiddlewareAccessLogFile (
72
+ expressApp : Application ,
73
+ logFilePath : string
74
+ ) : Application ;
75
+ setGlobal ( ) : void ;
64
76
65
- trace ( message : string , additionalFields ?: any ) : void ;
66
- debug ( message : string , additionalFields ?: any ) : void ;
67
- info ( message : string , additionalFields ?: any ) : void ;
68
- warn ( message : string , additionalFields ?: any ) : void ;
69
- error ( message : string , additionalFields ?: any ) : void ;
70
- fatal ( message : string , additionalFields ?: any ) : void ;
71
- raw ( message : any , support ?: boolean ) : void ;
77
+ trace ( message : string , additionalFields ?: any ) : void ;
78
+ debug ( message : string , additionalFields ?: any ) : void ;
79
+ info ( message : string , additionalFields ?: any ) : void ;
80
+ warn ( message : string , additionalFields ?: any ) : void ;
81
+ error ( message : string , additionalFields ?: any ) : void ;
82
+ fatal ( message : string , additionalFields ?: any ) : void ;
83
+ raw ( message : any , support ?: boolean ) : void ;
72
84
}
73
85
74
- export = ServiceLogger ;
86
+ export = ServiceLogger ;
0 commit comments