This repository has been archived by the owner on Apr 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 66
/
types.d.ts
113 lines (107 loc) · 4.51 KB
/
types.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
declare module "logdna" {
interface ConstructorOptions {
/** The default app passed along with every log sent through this instance. */
app?: string;
/** The default hostname passed along with every log sent through this instance. */
hostname?: string;
/** The default environment passed along with every log sent through this instance. */
env?: string;
/**
* We allow meta objects to be passed with each line. By default these meta objects
* will be stringified and will not be searchable, but will be displayed for informational
* purposes. If this option is turned to true then meta objects will be parsed and will be
* searchable up to three levels deep. Any fields deeper than three levels will be
* stringified and cannot be searched.
* WARNING: When this option is true, your metadata objects across all types of log
* messages MUST have consistent types or the metadata object may not be parsed properly!
*/
index_meta?: boolean;
/** The default IP Address passed along with every log sent through this instance. */
ip?: string;
/**
* The default level passed along with every log sent through this instance.
* Expected value is "Debug", "Trace", "Info", "Warn", "Error", "Fatal" or any custom
* level of your choice.
*/
level?: string;
/** The default MAC Address passed along with every log sent through this instance. */
mac?: string;
/**
* By default the line has a maximum length of 32000 chars, this can be turned off with
* the value false.
*/
max_length?: boolean;
/** The length of the timeout on the POST request that is sent to LogDNA. */
timeout?: number;
/**
* The withCredentials option passed to the request library. In order to make CORS
* requests this value is set to false by default.
*/
with_credentials?: boolean;
/**
* Alternate ingest URL
*/
logdna_url?: string;
tags?: string | string[];
}
interface LogOptions {
/**
* The level passed along with this log line.
* Expected value is "Debug", "Trace", "Info", "Warn", "Error", "Fatal" or any custom
* level of your choice.
*/
level?: string;
/** The app passed along with this log line. */
app?: string;
/** The environment passed along with this log line. */
env?: string;
/** A meta object that provides additional context about the log line that is passed. */
meta?: Object;
/**
* We allow meta objects to be passed with each line. By default these meta objects
* will be stringified and will not be searchable, but will be displayed for informational
* purposes. If this option is turned to true then meta objects will be parsed and will be
* searchable up to three levels deep. Any fields deeper than three levels will be
* stringified and cannot be searched.
* WARNING: When this option is true, your metadata objects across all types of log
* messages MUST have consistent types or the metadata object may not be parsed properly!
*/
index_meta?: boolean;
/**
* A timestamp in ms, must be within one day otherwise it will be dropped and Date.now()
* will be used in its place.
*/
timestamp?: number;
tags?: string | string[];
}
export interface Logger {
info(line: string, options?: Omit<LogOptions, 'level'>): void;
warn(line: string, options?: Omit<LogOptions, 'level'>): void;
debug(line: string, options?: Omit<LogOptions, 'level'>): void;
error(line: string, options?: Omit<LogOptions, 'level'>): void;
fatal(line: string, options?: Omit<LogOptions, 'level'>): void;
trace(line: string, options?: Omit<LogOptions, 'level'>): void;
log(line: string, options?: LogOptions): void;
/**
* Adds key/value pair into the logger's default meta.
*/
addMetaProperty(key: string, value: any): void;
/**
* Removes the key and associated value from the logger's default meta.
*/
removeMetaProperty(key: string): void;
}
export function createLogger(
key: string,
options?: ConstructorOptions
): Logger;
/**
* Flushes all existing loggers that are instantiated by createLogger.
*/
export function flushAll(callback?: (errMessage?: string) => void): void;
/**
* Flushes all existing loggers that are instantiated by createLogger, and then removes
* references to them. Should only be called when you are finished logging.
*/
export function cleanUpAll(callback?: (errMessage?: string) => void): void;
}