-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.d.ts
96 lines (96 loc) · 3.13 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
/**
* @author Ray Martone
* @copyright Copyright (c) 2019-2022 Ray Martone
* @license MIT
* @description log adapter that provides level based filtering and tagging
*/
/**
* Useful for implementing a log event hadnelr
*/
export declare enum LogLevel {
DEBUG = "DEBUG",
TRACE = "TRACE",
INFO = "INFO",
WARN = "WARN",
ERROR = "ERROR",
OFF = "OFF"
}
/**
* union
*/
export type LogLevelStr = 'DEBUG' | 'TRACE' | 'INFO' | 'WARN' | 'ERROR' | 'OFF';
/**
* Level where `ERROR > WARN > INFO`.
*/
declare enum Level {
DEBUG = 1,
TRACE = 2,
INFO = 3,
WARN = 4,
ERROR = 5,
OFF = 6
}
export type LogCallback = (level: LogLevelStr, tag: string, message: unknown, optionalParams: unknown[]) => void;
export declare const tag: Record<string, string>;
export declare class Log {
/**
* init assigns tags a level or they default to INFO
* _tagToLevel hash that maps tags to their level
*/
protected readonly _tagToLevel: Record<string, Level>;
/**
* callback that supports logging whatever way works best for you!
*/
protected _callback?: LogCallback;
/**
* init
* @param config? JSON that assigns tags levels. If uninitialized,
* a tag's level defaults to INFO where ERROR > WARN > INFO.
* @param callback? supports logging whatever way works best for you
* - style terminal output with chalk
* - send JSON to a cloud logging service like Splunk
* - log strings and objects to the browser console
* - combine any of the above based on your app's env
* @return {this} supports chaining
*/
init(config?: Record<string, string>, callback?: LogCallback): this;
/**
* Writes an error to the log
* @param tag string categorizes a message
* @param message object to log
* @param optionalParams optional list of objects to log
*/
error<T extends string>(tag: T, message: unknown, ...optionalParams: unknown[]): void;
/**
* Writes a warning to the log
* @param tag string categorizes a message
* @param message object to log
* @param optionalParams optional list of objects to log
*/
warn<T extends string>(tag: T, message: unknown, ...optionalParams: unknown[]): void;
/**
* Writes info to the log
* @param tag string categorizes a message
* @param message object to log
* @param optionalParams optional list of objects to log
*/
info<T extends string>(tag: T, message: unknown, ...optionalParams: unknown[]): void;
/**
* Writes trace to the log
* @param tag string categorizes a message
* @param message object to log
* @param optionalParams optional list of objects to log
*/
trace<T extends string>(tag: T, message: unknown, ...optionalParams: unknown[]): void;
/**
* Writes debug to the log
* @param tag string categorizes a message
* @param message object to log
* @param optionalParams optional list of objects to log
*/
debug<T extends string>(tag: T, message: unknown, ...optionalParams: unknown[]): void;
private log;
}
/** singleton Log instance */
export declare const log: Log;
export {};