-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
93 lines (80 loc) · 3.39 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import * as restify from 'restify';
import * as express from 'express';
// AccessLogger
export interface UserIdCallback {
(req: restify.Request|express.Request, res: restify.Response|express.Response): string;
}
export class AccessLogger {
constructor(appId: string);
public enable(enabled: boolean): void;
public setPretty(pretty: boolean): void;
public setStream(stream: {write: Function}): void;
public setAppId(appId: string): void;
public setUserIdCallback(callback: UserIdCallback): void;
public logRequest(req: restify.Request|express.Request, res: restify.Response|express.Response, next?: Function): void;
}
// AppLogger related interfaces and data
export enum LogLevel {
Silly = 0,
Verbose = 1,
Info = 2,
Warn = 3,
Error = 4
}
export interface Logger {
enable(enabled: boolean): void;
setAppId(appId: string): void;
getAppId(): string;
setLevel(level: LogLevel): void;
getLevel(): LogLevel;
setPretty(pretty: boolean): void;
setStream(stream: {write: Function}): void;
generateRequestId(): string;
log(level: LogLevel, message: string, id?: string, tags?: string[], details?: any): void;
silly(message: string, id?: string, tags?: string[], details?: any): void;
verbose(message: string, id?: string, tags?: string[], details?: any): void;
info(message: string, id?: string, tags?: string[], details?: any): void;
warn(message: string, id?: string, tags?: string[], details?: any): void;
error(message: string, id?: string, tags?: string[], details?: any): void;
getRequestLogger(requestId: string): RequestLogger;
}
export interface RequestLogger {
silly(message: string, tags?: string[], details?: any): void;
verbose(message: string, tags?: string[], details?: any): void;
info(message: string, tags?: string[], details?: any): void;
warn(message: string, tags?: string[], details?: any): void;
error(message: string, tags?: string[], details?: any): void;
}
// AppLogger
export class AppLogger implements Logger {
constructor(appId: string, level?: LogLevel, stream?: {write: Function});
public enable(enabled: boolean): void;
public setAppId(appId: string): void;
public getAppId(): string;
public setLevel(level: LogLevel): void;
public getLevel(): LogLevel;
public setPretty(pretty: boolean): void;
public setStream(stream: {write: Function}): void;
public generateRequestId(): string;
public log(level: LogLevel, message: string, id?: string, tags?: string[], details?: any): void;
public silly(message: string, id?: string, tags?: string[], details?: any): void;
public verbose(message: string, id?: string, tags?: string[], details?: any): void;
public info(message: string, id?: string, tags?: string[], details?: any): void;
public warn(message: string, id?: string, tags?: string[], details?: any): void;
public error(message: string, id?: string, tags?: string[], details?: any): void;
public getRequestLogger(requestId: string): RequestLogger;
}
// We augment the restify module to expose our custom Request.logger? type.
declare module 'restify' {
interface Request {
xRequestId?: string;
logger?: RequestLogger;
}
}
// We augment the express module to expose our custom Request.logger? type.
declare module 'express' {
interface Request {
xRequestId?: string;
logger?: RequestLogger;
}
}