forked from unjs/consola
/
consola.d.ts
98 lines (78 loc) 路 2.49 KB
/
consola.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
export interface ConsolaLogObject {
level?: number,
tag?: string,
type?: string,
message?: string,
additional?: string | string[],
args?: any[],
}
type ConsolaMock = (...args: any) => void
type ConsolaMockFn = (type: string, defaults: ConsolaLogObject) => ConsolaMock
export interface ConsolaReporterArgs {
async: boolean,
stdout: any,
stderr: any,
}
export interface ConsolaReporter {
log: (logObj: ConsolaLogObject, args: ConsolaReporterArgs) => void
}
export interface ConsolaOptions {
reporters?: ConsolaReporter[],
types?: { [type: string]: ConsolaLogObject },
level?: number,
defaults?: ConsolaLogObject,
async?: boolean,
stdout?: any,
stderr?: any,
mockFn?: ConsolaMockFn,
throttle?: number,
}
export declare class Consola {
constructor(options: ConsolaOptions)
level: number
readonly stdout: any
readonly stderr: any
// Built-in log levels
fatal(message: ConsolaLogObject | any, ...args: any[]): void
error(message: ConsolaLogObject | any, ...args: any[]): void
warn(message: ConsolaLogObject | any, ...args: any[]): void
log(message: ConsolaLogObject | any, ...args: any[]): void
info(message: ConsolaLogObject | any, ...args: any[]): void
start(message: ConsolaLogObject | any, ...args: any[]): void
success(message: ConsolaLogObject | any, ...args: any[]): void
ready(message: ConsolaLogObject | any, ...args: any[]): void
debug(message: ConsolaLogObject | any, ...args: any[]): void
trace(message: ConsolaLogObject | any, ...args: any[]): void
// Create
create(options: ConsolaOptions): Consola
withDefaults(defaults: ConsolaLogObject): Consola
withTag(tag: string): Consola
withScope(tag: string): Consola
// Reporter
addReporter(reporter: ConsolaReporter): Consola
setReporters(reporters: Array<ConsolaReporter>): Consola
removeReporter(reporter?: ConsolaReporter): Consola
remove(reporter?: ConsolaReporter): Consola
clear(reporter?: ConsolaReporter): Consola
// Wrappers
wrapAll(): void
restoreAll(): void
wrapConsole(): void
restoreConsole(): void
wrapStd(): void
restoreStd(): void
// Pause/Resume
pauseLogs(): void
pause(): void
resumeLogs(): void
resume(): void
// Mock
mockTypes(mockFn: ConsolaMockFn): any
mock(mockFn: ConsolaMockFn): any
}
export declare class BrowserReporter implements ConsolaReporter {
log: (logObj: ConsolaLogObject, args: ConsolaReporterArgs) => void
}
declare const consolaGlobalInstance: Consola;
export default consolaGlobalInstance
export = consolaGlobalInstance