forked from fullstack-build/tslog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterfaces.ts
161 lines (152 loc) · 4.32 KB
/
interfaces.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
import { IMeta, InspectOptions } from "./runtime/nodejs/index.js";
export type TStyle =
| null
| string
| string[]
| {
[value: string]: null | string | string[];
};
export interface ISettingsParam<LogObj> {
type?: "json" | "pretty" | "hidden";
name?: string;
parentNames?: string[];
minLevel?: number;
argumentsArrayName?: string;
prettyLogTemplate?: string;
prettyErrorTemplate?: string;
prettyErrorStackTemplate?: string;
prettyErrorParentNamesSeparator?: string;
prettyErrorLoggerNameDelimiter?: string;
stylePrettyLogs?: boolean;
prettyLogStyles?: {
yyyy?: TStyle;
mm?: TStyle;
dd?: TStyle;
hh?: TStyle;
MM?: TStyle;
ss?: TStyle;
ms?: TStyle;
dateIsoStr?: TStyle;
logLevelName?: TStyle;
fileName?: TStyle;
filePath?: TStyle;
fileLine?: TStyle;
filePathWithLine?: TStyle;
name?: TStyle;
nameWithDelimiterPrefix?: TStyle;
nameWithDelimiterSuffix?: TStyle;
errorName?: TStyle;
errorMessage?: TStyle;
};
prettyInspectOptions?: InspectOptions;
metaProperty?: string;
maskPlaceholder?: string;
maskValuesOfKeys?: string[];
maskValuesOfKeysCaseInsensitive?: boolean;
/** Mask all occurrences (case-sensitive) from values in logs (e.g. all secrets from ENVs etc.). Will be replaced with [***] */
maskValuesRegEx?: RegExp[];
/** Prefix every log message of this logger. */
prefix?: unknown[];
/** Array of attached Transports. Use Method `attachTransport` to attach transports. */
attachedTransports?: ((transportLogger: LogObj & ILogObjMeta) => void)[];
overwrite?: {
mask?: (args: unknown[]) => unknown[];
toLogObj?: (args: unknown[], clonesLogObj?: LogObj) => LogObj;
addMeta?: (logObj: LogObj, logLevelId: number, logLevelName: string) => LogObj & ILogObjMeta;
formatMeta?: (meta?: IMeta) => string;
formatLogObj?: (maskedArgs: unknown[], settings: ISettings<LogObj>) => { args: unknown[]; errors: string[] };
transportFormatted?: (logMetaMarkup: string, logArgs: unknown[], logErrors: string[], settings: ISettings<LogObj>) => void;
transportJSON?: (json: unknown) => void;
};
}
export interface ISettings<LogObj> extends ISettingsParam<LogObj> {
type: "json" | "pretty" | "hidden";
name?: string;
parentNames?: string[];
minLevel: number;
argumentsArrayName?: string;
prettyLogTemplate: string;
prettyErrorTemplate: string;
prettyErrorStackTemplate: string;
prettyErrorParentNamesSeparator: string;
prettyErrorLoggerNameDelimiter: string;
stylePrettyLogs: boolean;
prettyLogStyles: {
yyyy?: TStyle;
mm?: TStyle;
dd?: TStyle;
hh?: TStyle;
MM?: TStyle;
ss?: TStyle;
ms?: TStyle;
dateIsoStr?: TStyle;
logLevelName?: TStyle;
fileName?: TStyle;
filePath?: TStyle;
fileLine?: TStyle;
filePathWithLine?: TStyle;
name?: TStyle;
nameWithDelimiterPrefix?: TStyle;
nameWithDelimiterSuffix?: TStyle;
errorName?: TStyle;
errorMessage?: TStyle;
};
prettyInspectOptions: InspectOptions;
metaProperty: string;
maskPlaceholder: string;
maskValuesOfKeys: string[];
maskValuesOfKeysCaseInsensitive: boolean;
prefix: unknown[];
attachedTransports: ((transportLogger: LogObj & ILogObjMeta) => void)[];
}
export interface ILogObj {
[name: string]: unknown;
}
export interface ILogObjMeta {
[name: string]: IMeta;
}
export interface IStackFrame {
fullFilePath?: string;
fileName?: string;
filePath?: string;
fileLine?: string;
fileColumn?: string;
filePathWithLine?: string;
method?: string;
}
/**
* Object representing an error with a stack trace
* @public
*/
export interface IErrorObject {
/** Name of the error*/
name: string;
/** Error message */
message: string;
/** native Error object */
nativeError: Error;
/** Stack trace of the error */
stack: IStackFrame[];
}
/**
* ErrorObject that can safely be "JSON.stringifed". All circular structures have been "util.inspected" into strings
* @public
*/
export interface IErrorObjectStringifiable extends IErrorObject {
nativeError: never;
errorString: string;
}
/**
* Object representing an error with a stack trace
* @public
*/
export interface IErrorObject {
/** Name of the error*/
name: string;
/** Error message */
message: string;
/** native Error object */
nativeError: Error;
/** Stack trace of the error */
stack: IStackFrame[];
}