-
Notifications
You must be signed in to change notification settings - Fork 1
/
dblogger.d.ts
66 lines (55 loc) · 1.41 KB
/
dblogger.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
// template: http://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-function-d-ts.html
declare namespace dblogger {
enum Dummy {
// This is necessary so TS emits a require statement, since all other types in this
// namespace are compiled away.
}
export const enum LogLevel {
Trace = 10,
Debug = 20,
Info = 30,
Log = 30,
Warn = 40,
Error = 50,
Fatal = 60
}
export interface BaseOptions {
type: 'postgres' | 'sqlite' | 'none',
level: LogLevel,
/** Also log to stdout */
stdout: boolean,
/** Logger name */
logger: string,
}
export interface NoneOptions extends BaseOptions {
type: 'none',
}
export interface PostgresOptions extends BaseOptions {
type: 'postgres',
/** Database name */
name: string,
user: string,
password: string,
host: string,
port: number,
}
export interface SqliteOptions extends BaseOptions {
type: 'sqlite',
/** File name for sqlite */
name: string,
}
export type Options = PostgresOptions | SqliteOptions | NoneOptions;
export interface Logger {
trace(...args: any[]): void;
debug(...args: any[]): void;
info(...args: any[]): void;
log(...args: any[]): void;
warn(...args: any[]): void;
error(...args: any[]): void;
fatal(...args: any[]): void;
tag(...tag: string[]): Logger;
rotate(): void;
}
}
declare function dblogger(arg?: dblogger.Options | dblogger.LogLevel): dblogger.Logger;
export = dblogger;