-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.d.ts
79 lines (65 loc) · 1.75 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
declare namespace Logger {
export interface LevelConfig {
base: number
[K: string]: Level
}
export type Level = number | LevelConfig
export type Function = (format: any, ...param: any[]) => void
export type Type = 'success' | 'error' | 'info' | 'warn' | 'debug'
export type Formatter = (this: Logger, value: any) => string
export interface LabelStyle {
width?: number
margin?: number
align?: 'left' | 'right'
}
export interface Record {
id: number
meta: Meta
name: string
type: Type
level: number
content: string
timestamp: number
}
export interface Meta {}
export interface Target {
/**
* - 0: no color support
* - 1: 16 color support
* - 2: 256 color support
* - 3: truecolor support
*/
colors?: number
showDiff?: boolean
showTime?: string
label?: LabelStyle
record?(record: Record): void
print?(text: string): void
levels?: LevelConfig
timestamp?: number
}
}
declare interface Logger extends Record<Logger.Type, Logger.Function> {}
declare class Logger {
// log levels
static readonly SILENT = 0
static readonly SUCCESS = 1
static readonly ERROR = 1
static readonly INFO = 2
static readonly WARN = 2
static readonly DEBUG = 3
// global config
static colors: number[]
static instances: Record<string, Logger>
static targets: Logger.Target[]
static levels: Logger.LevelConfig
static formatters: Record<string, Logger.Formatter>
static color(code: number, value: any, decoration?: string): string
static code(name: string, target: Logger.Target): number
public name: string
public level: number
private code: number
constructor(name: string, meta?: any)
extend(namespace: string): Logger
}
export = Logger