forked from winstonjs/winston
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
193 lines (160 loc) · 5.31 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// Type definitions for winston 3.0
// Project: https://github.com/winstonjs/winston
/// <reference types="node" />
import * as NodeJSStream from "stream";
import * as logform from 'logform';
import * as Transport from 'winston-transport';
import * as Config from './lib/winston/config/index';
import * as Transports from './lib/winston/transports/index';
declare namespace winston {
// Hoisted namespaces from other modules
export import format = logform.format;
export import Logform = logform;
export import config = Config;
export import transports = Transports;
export import transport = Transport;
interface ExceptionHandler {
logger: Logger;
handlers: Map<any, any>;
catcher: Function | boolean;
handle(...transports: Transport[]): void;
unhandle(...transports: Transport[]): void;
getAllInfo(err: string | Error): object;
getProcessInfo(): object;
getOsInfo(): object;
getTrace(err: Error): object;
new(logger: Logger): ExceptionHandler;
}
interface QueryOptions {
rows?: number;
limit?: number;
start?: number;
from?: Date;
until?: Date;
order?: "asc" | "desc";
fields: any;
}
interface Profiler {
logger: Logger;
start: Date;
done(info?: any): boolean;
}
type LogCallback = (error?: any, level?: string, message?: string, meta?: any) => void;
interface LogEntry {
level: string;
message: string;
[optionName: string]: any;
}
interface LogMethod {
(level: string, message: string, callback: LogCallback): Logger;
(level: string, message: string, meta: any, callback: LogCallback): Logger;
(level: string, message: string, ...meta: any[]): Logger;
(entry: LogEntry): Logger;
(level: string, message: any): Logger;
}
interface LeveledLogMethod {
(message: string, callback: LogCallback): Logger;
(message: string, meta: any, callback: LogCallback): Logger;
(message: string, ...meta: any[]): Logger;
(message: any): Logger;
(infoObject: object): Logger;
}
interface LoggerOptions {
levels?: Config.AbstractConfigSetLevels;
silent?: boolean;
format?: logform.Format;
level?: string;
exitOnError?: Function | boolean;
defaultMeta?: any;
transports?: Transport[] | Transport;
handleExceptions?: boolean;
exceptionHandlers?: any;
}
interface Logger extends NodeJSStream.Transform {
silent: boolean;
format: logform.Format;
levels: Config.AbstractConfigSetLevels;
level: string;
transports: Transport[];
exceptions: ExceptionHandler;
profilers: object;
exitOnError: Function | boolean;
defaultMeta?: any;
log: LogMethod;
add(transport: Transport): Logger;
remove(transport: Transport): Logger;
clear(): Logger;
close(): Logger;
// for cli and npm levels
error: LeveledLogMethod;
warn: LeveledLogMethod;
help: LeveledLogMethod;
data: LeveledLogMethod;
info: LeveledLogMethod;
debug: LeveledLogMethod;
prompt: LeveledLogMethod;
http: LeveledLogMethod;
verbose: LeveledLogMethod;
input: LeveledLogMethod;
silly: LeveledLogMethod;
// for syslog levels only
emerg: LeveledLogMethod;
alert: LeveledLogMethod;
crit: LeveledLogMethod;
warning: LeveledLogMethod;
notice: LeveledLogMethod;
query(options?: QueryOptions, callback?: (err: Error, results: any) => void): any;
stream(options?: any): NodeJS.ReadableStream;
startTimer(): Profiler;
profile(id: string | number, meta?: LogEntry): Logger;
configure(options: LoggerOptions): void;
child(options: Object): Logger;
isLevelEnabled(level: string): boolean;
isErrorEnabled(): boolean;
isWarnEnabled(): boolean;
isInfoEnabled(): boolean;
isVerboseEnabled(): boolean;
isDebugEnabled(): boolean;
isSillyEnabled(): boolean;
new(options?: LoggerOptions): Logger;
}
interface Container {
loggers: Map<string, Logger>;
options: LoggerOptions;
add(id: string, options?: LoggerOptions): Logger;
get(id: string, options?: LoggerOptions): Logger;
has(id: string): boolean;
close(id?: string): void;
new(options?: LoggerOptions): Container;
}
let version: string;
let ExceptionHandler: ExceptionHandler;
let Container: Container;
let loggers: Container;
let addColors: (target: Config.AbstractConfigSetColors) => any;
let createLogger: (options?: LoggerOptions) => Logger;
// Pass-through npm level methods routed to the default logger.
let error: LeveledLogMethod;
let warn: LeveledLogMethod;
let info: LeveledLogMethod;
let http: LeveledLogMethod;
let verbose: LeveledLogMethod;
let debug: LeveledLogMethod;
let silly: LeveledLogMethod;
// Other pass-through methods routed to the default logger.
let log: LogMethod;
let query: (options?: QueryOptions, callback?: (err: Error, results: any) => void) => any;
let stream: (options?: any) => NodeJS.ReadableStream;
let add: (transport: Transport) => Logger;
let remove: (transport: Transport) => Logger;
let clear: () => Logger;
let startTimer: () => Profiler;
let profile: (id: string | number) => Logger;
let configure: (options: LoggerOptions) => void;
let child: (options: Object) => Logger;
let level: string;
let exceptions: ExceptionHandler;
let exitOnError: Function | boolean;
// let default: object;
}
export = winston;