|
1 |
| -declare interface ConsolaReporter { |
2 |
| - log: (logObj: any, { async, stdout, stderr }: any) => void |
| 1 | +export interface ConsolaLogObject { |
| 2 | + level?: number, |
| 3 | + tag?: string, |
| 4 | + type?: string, |
| 5 | + message?: string, |
| 6 | + additional?: string | string[], |
| 7 | + args?: any[], |
3 | 8 | }
|
4 | 9 |
|
5 |
| -declare class Consola { |
| 10 | +type ConsolaMock = (...args: any) => void |
| 11 | + |
| 12 | +type ConsolaMockFn = (type: string, defaults: ConsolaLogObject) => ConsolaMock |
| 13 | + |
| 14 | +export interface ConsolaReporterArgs { |
| 15 | + async: boolean, |
| 16 | + stdout: any, |
| 17 | + stderr: any, |
| 18 | +} |
| 19 | + |
| 20 | +export interface ConsolaReporter { |
| 21 | + log: (logObj: ConsolaLogObject, args: ConsolaReporterArgs) => void |
| 22 | +} |
| 23 | + |
| 24 | +export interface ConsolaOptions { |
| 25 | + reporters?: ConsolaReporter[], |
| 26 | + types?: { [type: string]: ConsolaLogObject }, |
| 27 | + level?: number, |
| 28 | + defaults?: ConsolaLogObject, |
| 29 | + async?: boolean, |
| 30 | + stdout?: any, |
| 31 | + stderr?: any, |
| 32 | + mockFn?: ConsolaMockFn, |
| 33 | + throttle?: number, |
| 34 | +} |
| 35 | + |
| 36 | +export declare class Consola { |
| 37 | + constructor(options: ConsolaOptions) |
| 38 | + |
6 | 39 | // Built-in log levels
|
7 |
| - static fatal(message: any, ...args: any[]): void |
8 |
| - static error(message: any, ...args: any[]): void |
9 |
| - static warn(message: any, ...args: any[]): void |
10 |
| - static log(message: any, ...args: any[]): void |
11 |
| - static info(message: any, ...args: any[]): void |
12 |
| - static start(message: any, ...args: any[]): void |
13 |
| - static success(message: any, ...args: any[]): void |
14 |
| - static ready(message: any, ...args: any[]): void |
15 |
| - static debug(message: any, ...args: any[]): void |
16 |
| - static trace(message: any, ...args: any[]): void |
| 40 | + fatal(message: ConsolaLogObject | any, ...args: any[]): void |
| 41 | + error(message: ConsolaLogObject | any, ...args: any[]): void |
| 42 | + warn(message: ConsolaLogObject | any, ...args: any[]): void |
| 43 | + log(message: ConsolaLogObject | any, ...args: any[]): void |
| 44 | + info(message: ConsolaLogObject | any, ...args: any[]): void |
| 45 | + start(message: ConsolaLogObject | any, ...args: any[]): void |
| 46 | + success(message: ConsolaLogObject | any, ...args: any[]): void |
| 47 | + ready(message: ConsolaLogObject | any, ...args: any[]): void |
| 48 | + debug(message: ConsolaLogObject | any, ...args: any[]): void |
| 49 | + trace(message: ConsolaLogObject | any, ...args: any[]): void |
17 | 50 |
|
18 | 51 | // Create
|
19 |
| - static create(options: any): typeof Consola |
20 |
| - static withDefaults(defaults: any): typeof Consola |
| 52 | + create(options: ConsolaOptions): Consola |
| 53 | + withDefaults(defaults: ConsolaLogObject): Consola |
21 | 54 |
|
22 |
| - static withTag(tag: string): typeof Consola |
23 |
| - static withScope(tag: string): typeof Consola |
| 55 | + withTag(tag: string): Consola |
| 56 | + withScope(tag: string): Consola |
24 | 57 |
|
25 | 58 | // Reporter
|
26 |
| - static addReporter(reporter: ConsolaReporter): typeof Consola |
27 |
| - static setReporters(reporters: Array<ConsolaReporter>): typeof Consola |
| 59 | + addReporter(reporter: ConsolaReporter): Consola |
| 60 | + setReporters(reporters: Array<ConsolaReporter>): Consola |
28 | 61 |
|
29 |
| - static removeReporter(reporter: any): typeof Consola |
30 |
| - static remove(reporter: any): typeof Consola |
31 |
| - static clear(reporter: any): typeof Consola |
| 62 | + removeReporter(reporter: ConsolaReporter): Consola |
| 63 | + remove(reporter: ConsolaReporter): Consola |
| 64 | + clear(reporter: ConsolaReporter): Consola |
32 | 65 |
|
33 | 66 | // Wrappers
|
34 |
| - static wrapAll(): void |
35 |
| - static restoreAll(): void |
36 |
| - static wrapConsole(): void |
37 |
| - static restoreConsole(): void |
38 |
| - static wrapStd(): void |
39 |
| - static restoreStd(): void |
| 67 | + wrapAll(): void |
| 68 | + restoreAll(): void |
| 69 | + wrapConsole(): void |
| 70 | + restoreConsole(): void |
| 71 | + wrapStd(): void |
| 72 | + restoreStd(): void |
40 | 73 |
|
41 | 74 | // Pause/Resume
|
42 |
| - static pauseLogs(): void |
43 |
| - static pause(): void |
| 75 | + pauseLogs(): void |
| 76 | + pause(): void |
44 | 77 |
|
45 |
| - static resumeLogs(): void |
46 |
| - static resume(): void |
| 78 | + resumeLogs(): void |
| 79 | + resume(): void |
47 | 80 |
|
48 | 81 | // Mock
|
49 |
| - static mockTypes(mockFn: any): any |
50 |
| - static mock(mockFn: any): any |
| 82 | + mockTypes(mockFn: ConsolaMockFn): any |
| 83 | + mock(mockFn: ConsolaMockFn): any |
51 | 84 | }
|
52 | 85 |
|
53 |
| -declare module 'consola' { |
54 |
| - export default Consola |
| 86 | +export declare class BrowserReporter implements ConsolaReporter { |
| 87 | + log: (logObj: ConsolaLogObject, args: ConsolaReporterArgs) => void |
55 | 88 | }
|
| 89 | + |
| 90 | +declare const consolaGlobalInstance: Consola; |
| 91 | + |
| 92 | +export default consolaGlobalInstance |
0 commit comments