winston-prisma 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +19 -0
- package/README.md +1236 -0
- package/dist/winston.js +157 -0
- package/dist/winston_prisma/common.js +45 -0
- package/dist/winston_prisma/config/index.js +37 -0
- package/dist/winston_prisma/config/prisma-config.js +32 -0
- package/dist/winston_prisma/container.js +114 -0
- package/dist/winston_prisma/create-logger.js +104 -0
- package/dist/winston_prisma/exception-handler.js +228 -0
- package/dist/winston_prisma/exception-stream.js +56 -0
- package/dist/winston_prisma/logger.js +608 -0
- package/dist/winston_prisma/profiler.js +52 -0
- package/dist/winston_prisma/rejection-handler.js +228 -0
- package/dist/winston_prisma/tail-file.js +115 -0
- package/dist/winston_prisma/transports/console.js +110 -0
- package/dist/winston_prisma/transports/file.js +670 -0
- package/dist/winston_prisma/transports/http.js +238 -0
- package/dist/winston_prisma/transports/index.js +56 -0
- package/dist/winston_prisma/transports/stream.js +63 -0
- package/index.d.ts +220 -0
- package/lib/winston.js +180 -0
- package/lib/winston_prisma/common.js +46 -0
- package/lib/winston_prisma/config/index.d.ts +99 -0
- package/lib/winston_prisma/config/index.js +35 -0
- package/lib/winston_prisma/config/prisma-config.js +32 -0
- package/lib/winston_prisma/container.js +118 -0
- package/lib/winston_prisma/create-logger.js +104 -0
- package/lib/winston_prisma/exception-handler.js +245 -0
- package/lib/winston_prisma/exception-stream.js +54 -0
- package/lib/winston_prisma/logger.js +676 -0
- package/lib/winston_prisma/profiler.js +53 -0
- package/lib/winston_prisma/rejection-handler.js +251 -0
- package/lib/winston_prisma/tail-file.js +124 -0
- package/lib/winston_prisma/transports/console.js +117 -0
- package/lib/winston_prisma/transports/file.js +732 -0
- package/lib/winston_prisma/transports/http.js +258 -0
- package/lib/winston_prisma/transports/index.d.ts +106 -0
- package/lib/winston_prisma/transports/index.js +56 -0
- package/lib/winston_prisma/transports/stream.js +63 -0
- package/package.json +74 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* http.js: Transport for outputting to a json-rpcserver.
|
|
3
|
+
*
|
|
4
|
+
* (C) 2010 Charlie Robbins
|
|
5
|
+
* MIT LICENCE
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const http = require('http');
|
|
11
|
+
const https = require('https');
|
|
12
|
+
const {
|
|
13
|
+
Stream
|
|
14
|
+
} = require('readable-stream');
|
|
15
|
+
const TransportStream = require('winston-transport');
|
|
16
|
+
const jsonStringify = require('safe-stable-stringify');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Transport for outputting to a json-rpc server.
|
|
20
|
+
* @type {Stream}
|
|
21
|
+
* @extends {TransportStream}
|
|
22
|
+
*/
|
|
23
|
+
module.exports = class Http extends TransportStream {
|
|
24
|
+
/**
|
|
25
|
+
* Constructor function for the Http transport object responsible for
|
|
26
|
+
* persisting log messages and metadata to a terminal or TTY.
|
|
27
|
+
* @param {!Object} [options={}] - Options for this instance.
|
|
28
|
+
*/
|
|
29
|
+
// eslint-disable-next-line max-statements
|
|
30
|
+
constructor(options = {}) {
|
|
31
|
+
super(options);
|
|
32
|
+
this.options = options;
|
|
33
|
+
this.name = options.name || 'http';
|
|
34
|
+
this.ssl = !!options.ssl;
|
|
35
|
+
this.host = options.host || 'localhost';
|
|
36
|
+
this.port = options.port;
|
|
37
|
+
this.auth = options.auth;
|
|
38
|
+
this.path = options.path || '';
|
|
39
|
+
this.agent = options.agent;
|
|
40
|
+
this.headers = options.headers || {};
|
|
41
|
+
this.headers['content-type'] = 'application/json';
|
|
42
|
+
this.batch = options.batch || false;
|
|
43
|
+
this.batchInterval = options.batchInterval || 5000;
|
|
44
|
+
this.batchCount = options.batchCount || 10;
|
|
45
|
+
this.batchOptions = [];
|
|
46
|
+
this.batchTimeoutID = -1;
|
|
47
|
+
this.batchCallback = {};
|
|
48
|
+
if (!this.port) {
|
|
49
|
+
this.port = this.ssl ? 443 : 80;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Core logging method exposed to Winston.
|
|
55
|
+
* @param {Object} info - TODO: add param description.
|
|
56
|
+
* @param {function} callback - TODO: add param description.
|
|
57
|
+
* @returns {undefined}
|
|
58
|
+
*/
|
|
59
|
+
log(info, callback) {
|
|
60
|
+
this._request(info, null, null, (err, res) => {
|
|
61
|
+
if (res && res.statusCode !== 200) {
|
|
62
|
+
err = new Error(`Invalid HTTP Status Code: ${res.statusCode}`);
|
|
63
|
+
}
|
|
64
|
+
if (err) {
|
|
65
|
+
this.emit('warn', err);
|
|
66
|
+
} else {
|
|
67
|
+
this.emit('logged', info);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Remark: (jcrugzz) Fire and forget here so requests dont cause buffering
|
|
72
|
+
// and block more requests from happening?
|
|
73
|
+
if (callback) {
|
|
74
|
+
setImmediate(callback);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Query the transport. Options object is optional.
|
|
80
|
+
* @param {Object} options - Loggly-like query options for this instance.
|
|
81
|
+
* @param {function} callback - Continuation to respond to when complete.
|
|
82
|
+
* @returns {undefined}
|
|
83
|
+
*/
|
|
84
|
+
query(options, callback) {
|
|
85
|
+
if (typeof options === 'function') {
|
|
86
|
+
callback = options;
|
|
87
|
+
options = {};
|
|
88
|
+
}
|
|
89
|
+
options = {
|
|
90
|
+
method: 'query',
|
|
91
|
+
params: this.normalizeQuery(options)
|
|
92
|
+
};
|
|
93
|
+
const auth = options.params.auth || null;
|
|
94
|
+
delete options.params.auth;
|
|
95
|
+
const path = options.params.path || null;
|
|
96
|
+
delete options.params.path;
|
|
97
|
+
this._request(options, auth, path, (err, res, body) => {
|
|
98
|
+
if (res && res.statusCode !== 200) {
|
|
99
|
+
err = new Error(`Invalid HTTP Status Code: ${res.statusCode}`);
|
|
100
|
+
}
|
|
101
|
+
if (err) {
|
|
102
|
+
return callback(err);
|
|
103
|
+
}
|
|
104
|
+
if (typeof body === 'string') {
|
|
105
|
+
try {
|
|
106
|
+
body = JSON.parse(body);
|
|
107
|
+
} catch (e) {
|
|
108
|
+
return callback(e);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
callback(null, body);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Returns a log stream for this transport. Options object is optional.
|
|
117
|
+
* @param {Object} options - Stream options for this instance.
|
|
118
|
+
* @returns {Stream} - TODO: add return description
|
|
119
|
+
*/
|
|
120
|
+
stream(options = {}) {
|
|
121
|
+
const stream = new Stream();
|
|
122
|
+
options = {
|
|
123
|
+
method: 'stream',
|
|
124
|
+
params: options
|
|
125
|
+
};
|
|
126
|
+
const path = options.params.path || null;
|
|
127
|
+
delete options.params.path;
|
|
128
|
+
const auth = options.params.auth || null;
|
|
129
|
+
delete options.params.auth;
|
|
130
|
+
let buff = '';
|
|
131
|
+
const req = this._request(options, auth, path);
|
|
132
|
+
stream.destroy = () => req.destroy();
|
|
133
|
+
req.on('data', data => {
|
|
134
|
+
data = (buff + data).split(/\n+/);
|
|
135
|
+
const l = data.length - 1;
|
|
136
|
+
let i = 0;
|
|
137
|
+
for (; i < l; i++) {
|
|
138
|
+
try {
|
|
139
|
+
stream.emit('log', JSON.parse(data[i]));
|
|
140
|
+
} catch (e) {
|
|
141
|
+
stream.emit('error', e);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
buff = data[l];
|
|
145
|
+
});
|
|
146
|
+
req.on('error', err => stream.emit('error', err));
|
|
147
|
+
return stream;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Make a request to a winstond server or any http server which can
|
|
152
|
+
* handle json-rpc.
|
|
153
|
+
* @param {function} options - Options to sent the request.
|
|
154
|
+
* @param {Object?} auth - authentication options
|
|
155
|
+
* @param {string} path - request path
|
|
156
|
+
* @param {function} callback - Continuation to respond to when complete.
|
|
157
|
+
*/
|
|
158
|
+
_request(options, auth, path, callback) {
|
|
159
|
+
options = options || {};
|
|
160
|
+
auth = auth || this.auth;
|
|
161
|
+
path = path || this.path || '';
|
|
162
|
+
if (this.batch) {
|
|
163
|
+
this._doBatch(options, callback, auth, path);
|
|
164
|
+
} else {
|
|
165
|
+
this._doRequest(options, callback, auth, path);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Send or memorize the options according to batch configuration
|
|
171
|
+
* @param {function} options - Options to sent the request.
|
|
172
|
+
* @param {function} callback - Continuation to respond to when complete.
|
|
173
|
+
* @param {Object?} auth - authentication options
|
|
174
|
+
* @param {string} path - request path
|
|
175
|
+
*/
|
|
176
|
+
_doBatch(options, callback, auth, path) {
|
|
177
|
+
this.batchOptions.push(options);
|
|
178
|
+
if (this.batchOptions.length === 1) {
|
|
179
|
+
// First message stored, it's time to start the timeout!
|
|
180
|
+
const me = this;
|
|
181
|
+
this.batchCallback = callback;
|
|
182
|
+
this.batchTimeoutID = setTimeout(function () {
|
|
183
|
+
// timeout is reached, send all messages to endpoint
|
|
184
|
+
me.batchTimeoutID = -1;
|
|
185
|
+
me._doBatchRequest(me.batchCallback, auth, path);
|
|
186
|
+
}, this.batchInterval);
|
|
187
|
+
}
|
|
188
|
+
if (this.batchOptions.length === this.batchCount) {
|
|
189
|
+
// max batch count is reached, send all messages to endpoint
|
|
190
|
+
this._doBatchRequest(this.batchCallback, auth, path);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Initiate a request with the memorized batch options, stop the batch timeout
|
|
196
|
+
* @param {function} callback - Continuation to respond to when complete.
|
|
197
|
+
* @param {Object?} auth - authentication options
|
|
198
|
+
* @param {string} path - request path
|
|
199
|
+
*/
|
|
200
|
+
_doBatchRequest(callback, auth, path) {
|
|
201
|
+
if (this.batchTimeoutID > 0) {
|
|
202
|
+
clearTimeout(this.batchTimeoutID);
|
|
203
|
+
this.batchTimeoutID = -1;
|
|
204
|
+
}
|
|
205
|
+
const batchOptionsCopy = this.batchOptions.slice();
|
|
206
|
+
this.batchOptions = [];
|
|
207
|
+
this._doRequest(batchOptionsCopy, callback, auth, path);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Make a request to a winstond server or any http server which can
|
|
212
|
+
* handle json-rpc.
|
|
213
|
+
* @param {function} options - Options to sent the request.
|
|
214
|
+
* @param {function} callback - Continuation to respond to when complete.
|
|
215
|
+
* @param {Object?} auth - authentication options
|
|
216
|
+
* @param {string} path - request path
|
|
217
|
+
*/
|
|
218
|
+
_doRequest(options, callback, auth, path) {
|
|
219
|
+
// Prepare options for outgoing HTTP request
|
|
220
|
+
const headers = Object.assign({}, this.headers);
|
|
221
|
+
if (auth && auth.bearer) {
|
|
222
|
+
headers.Authorization = `Bearer ${auth.bearer}`;
|
|
223
|
+
}
|
|
224
|
+
const req = (this.ssl ? https : http).request({
|
|
225
|
+
...this.options,
|
|
226
|
+
method: 'POST',
|
|
227
|
+
host: this.host,
|
|
228
|
+
port: this.port,
|
|
229
|
+
path: `/${path.replace(/^\//, '')}`,
|
|
230
|
+
headers: headers,
|
|
231
|
+
auth: auth && auth.username && auth.password ? `${auth.username}:${auth.password}` : '',
|
|
232
|
+
agent: this.agent
|
|
233
|
+
});
|
|
234
|
+
req.on('error', callback);
|
|
235
|
+
req.on('response', res => res.on('end', () => callback(null, res)).resume());
|
|
236
|
+
req.end(Buffer.from(jsonStringify(options, this.options.replacer), 'utf8'));
|
|
237
|
+
}
|
|
238
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* transports.js: Set of all transports Winston knows about.
|
|
3
|
+
*
|
|
4
|
+
* (C) 2010 Charlie Robbins
|
|
5
|
+
* MIT LICENCE
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* TODO: add property description.
|
|
12
|
+
* @type {Console}
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, 'Console', {
|
|
15
|
+
configurable: true,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get() {
|
|
18
|
+
return require('./console');
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* TODO: add property description.
|
|
24
|
+
* @type {File}
|
|
25
|
+
*/
|
|
26
|
+
Object.defineProperty(exports, 'File', {
|
|
27
|
+
configurable: true,
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get() {
|
|
30
|
+
return require('./file');
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* TODO: add property description.
|
|
36
|
+
* @type {Http}
|
|
37
|
+
*/
|
|
38
|
+
Object.defineProperty(exports, 'Http', {
|
|
39
|
+
configurable: true,
|
|
40
|
+
enumerable: true,
|
|
41
|
+
get() {
|
|
42
|
+
return require('./http');
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* TODO: add property description.
|
|
48
|
+
* @type {Stream}
|
|
49
|
+
*/
|
|
50
|
+
Object.defineProperty(exports, 'Stream', {
|
|
51
|
+
configurable: true,
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get() {
|
|
54
|
+
return require('./stream');
|
|
55
|
+
}
|
|
56
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* stream.js: Transport for outputting to any arbitrary stream.
|
|
3
|
+
*
|
|
4
|
+
* (C) 2010 Charlie Robbins
|
|
5
|
+
* MIT LICENCE
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
const isStream = require('is-stream');
|
|
11
|
+
const {
|
|
12
|
+
MESSAGE
|
|
13
|
+
} = require('triple-beam');
|
|
14
|
+
const os = require('os');
|
|
15
|
+
const TransportStream = require('winston-transport');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Transport for outputting to any arbitrary stream.
|
|
19
|
+
* @type {Stream}
|
|
20
|
+
* @extends {TransportStream}
|
|
21
|
+
*/
|
|
22
|
+
module.exports = class Stream extends TransportStream {
|
|
23
|
+
/**
|
|
24
|
+
* Constructor function for the Console transport object responsible for
|
|
25
|
+
* persisting log messages and metadata to a terminal or TTY.
|
|
26
|
+
* @param {!Object} [options={}] - Options for this instance.
|
|
27
|
+
*/
|
|
28
|
+
constructor(options = {}) {
|
|
29
|
+
super(options);
|
|
30
|
+
if (!options.stream || !isStream(options.stream)) {
|
|
31
|
+
throw new Error('options.stream is required.');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// We need to listen for drain events when write() returns false. This can
|
|
35
|
+
// make node mad at times.
|
|
36
|
+
this._stream = options.stream;
|
|
37
|
+
this._stream.setMaxListeners(Infinity);
|
|
38
|
+
this.isObjectMode = options.stream._writableState.objectMode;
|
|
39
|
+
this.eol = typeof options.eol === 'string' ? options.eol : os.EOL;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Core logging method exposed to Winston.
|
|
44
|
+
* @param {Object} info - TODO: add param description.
|
|
45
|
+
* @param {Function} callback - TODO: add param description.
|
|
46
|
+
* @returns {undefined}
|
|
47
|
+
*/
|
|
48
|
+
log(info, callback) {
|
|
49
|
+
setImmediate(() => this.emit('logged', info));
|
|
50
|
+
if (this.isObjectMode) {
|
|
51
|
+
this._stream.write(info);
|
|
52
|
+
if (callback) {
|
|
53
|
+
callback(); // eslint-disable-line callback-return
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
this._stream.write(`${info[MESSAGE]}${this.eol}`);
|
|
58
|
+
if (callback) {
|
|
59
|
+
callback(); // eslint-disable-line callback-return
|
|
60
|
+
}
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// Type definitions for winston 3.0
|
|
2
|
+
// Project: https://github.com/winstonjs/winston
|
|
3
|
+
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
|
|
6
|
+
import * as NodeJSStream from 'stream';
|
|
7
|
+
|
|
8
|
+
import * as logform from 'logform';
|
|
9
|
+
import * as Transport from 'winston-transport';
|
|
10
|
+
|
|
11
|
+
import * as Config from './lib/winston_prisma/config/index';
|
|
12
|
+
import * as Prisma from "./lib/winston_prisma/config/prisma-config"
|
|
13
|
+
import * as Transports from './lib/winston_prisma/transports/index';
|
|
14
|
+
|
|
15
|
+
declare namespace winston {
|
|
16
|
+
// Hoisted namespaces from other modules
|
|
17
|
+
export import format = logform.format;
|
|
18
|
+
export import Logform = logform;
|
|
19
|
+
export import config = Config;
|
|
20
|
+
export import transports = Transports;
|
|
21
|
+
export import transport = Transport;
|
|
22
|
+
export import prismalog = Prisma;
|
|
23
|
+
class ExceptionHandler {
|
|
24
|
+
constructor(logger: Logger);
|
|
25
|
+
logger: Logger;
|
|
26
|
+
handlers: Map<any, any>;
|
|
27
|
+
catcher: Function | boolean;
|
|
28
|
+
|
|
29
|
+
handle(...transports: Transport[]): void;
|
|
30
|
+
unhandle(...transports: Transport[]): void;
|
|
31
|
+
getAllInfo(err: string | Error): object;
|
|
32
|
+
getProcessInfo(): object;
|
|
33
|
+
getOsInfo(): object;
|
|
34
|
+
getTrace(err: Error): object;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
class RejectionHandler {
|
|
38
|
+
constructor(logger: Logger);
|
|
39
|
+
logger: Logger;
|
|
40
|
+
handlers: Map<any, any>;
|
|
41
|
+
catcher: Function | boolean;
|
|
42
|
+
|
|
43
|
+
handle(...transports: Transport[]): void;
|
|
44
|
+
unhandle(...transports: Transport[]): void;
|
|
45
|
+
getAllInfo(err: string | Error): object;
|
|
46
|
+
getProcessInfo(): object;
|
|
47
|
+
getOsInfo(): object;
|
|
48
|
+
getTrace(err: Error): object;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface QueryOptions {
|
|
52
|
+
rows?: number;
|
|
53
|
+
limit?: number;
|
|
54
|
+
start?: number;
|
|
55
|
+
from?: Date;
|
|
56
|
+
until?: Date;
|
|
57
|
+
order?: 'asc' | 'desc';
|
|
58
|
+
fields: any;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
class Profiler {
|
|
62
|
+
logger: Logger;
|
|
63
|
+
start: Number;
|
|
64
|
+
done(info?: any): boolean;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
type LogCallback = (
|
|
68
|
+
error?: any,
|
|
69
|
+
level?: string,
|
|
70
|
+
message?: string,
|
|
71
|
+
meta?: any
|
|
72
|
+
) => void;
|
|
73
|
+
|
|
74
|
+
interface LogEntry {
|
|
75
|
+
level: string;
|
|
76
|
+
message: string;
|
|
77
|
+
[optionName: string]: any;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface LogMethod {
|
|
81
|
+
(level: string, message: string, callback: LogCallback): Logger;
|
|
82
|
+
(level: string, message: string, meta: any, callback: LogCallback): Logger;
|
|
83
|
+
(level: string, message: string, ...meta: any[]): Logger;
|
|
84
|
+
(entry: LogEntry): Logger;
|
|
85
|
+
(level: string, message: any): Logger;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
interface LeveledLogMethod {
|
|
89
|
+
(message: string, callback: LogCallback): Logger;
|
|
90
|
+
(message: string, meta: any, callback: LogCallback): Logger;
|
|
91
|
+
(message: string, ...meta: any[]): Logger;
|
|
92
|
+
(message: any): Logger;
|
|
93
|
+
(infoObject: object): Logger;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
interface LoggerOptions {
|
|
97
|
+
levels?: Config.AbstractConfigSetLevels;
|
|
98
|
+
silent?: boolean;
|
|
99
|
+
format?: logform.Format;
|
|
100
|
+
level?: string;
|
|
101
|
+
exitOnError?: Function | boolean;
|
|
102
|
+
defaultMeta?: any;
|
|
103
|
+
transports?: Transport[] | Transport;
|
|
104
|
+
handleExceptions?: boolean;
|
|
105
|
+
handleRejections?: boolean;
|
|
106
|
+
exceptionHandlers?: any;
|
|
107
|
+
rejectionHandlers?: any;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
class Logger extends NodeJSStream.Transform {
|
|
111
|
+
constructor(options?: LoggerOptions);
|
|
112
|
+
|
|
113
|
+
silent: boolean;
|
|
114
|
+
format: logform.Format;
|
|
115
|
+
levels: Config.AbstractConfigSetLevels;
|
|
116
|
+
level: string;
|
|
117
|
+
transports: Transport[];
|
|
118
|
+
exceptions: ExceptionHandler;
|
|
119
|
+
rejections: RejectionHandler;
|
|
120
|
+
profilers: object;
|
|
121
|
+
exitOnError: Function | boolean;
|
|
122
|
+
defaultMeta?: any;
|
|
123
|
+
|
|
124
|
+
log: LogMethod;
|
|
125
|
+
add(transport: Transport): this;
|
|
126
|
+
remove(transport: Transport): this;
|
|
127
|
+
clear(): this;
|
|
128
|
+
close(): this;
|
|
129
|
+
|
|
130
|
+
// for cli and npm levels
|
|
131
|
+
error: LeveledLogMethod;
|
|
132
|
+
warn: LeveledLogMethod;
|
|
133
|
+
help: LeveledLogMethod;
|
|
134
|
+
data: LeveledLogMethod;
|
|
135
|
+
info: LeveledLogMethod;
|
|
136
|
+
debug: LeveledLogMethod;
|
|
137
|
+
prompt: LeveledLogMethod;
|
|
138
|
+
http: LeveledLogMethod;
|
|
139
|
+
verbose: LeveledLogMethod;
|
|
140
|
+
input: LeveledLogMethod;
|
|
141
|
+
silly: LeveledLogMethod;
|
|
142
|
+
|
|
143
|
+
// for syslog levels only
|
|
144
|
+
emerg: LeveledLogMethod;
|
|
145
|
+
alert: LeveledLogMethod;
|
|
146
|
+
crit: LeveledLogMethod;
|
|
147
|
+
warning: LeveledLogMethod;
|
|
148
|
+
notice: LeveledLogMethod;
|
|
149
|
+
|
|
150
|
+
query(
|
|
151
|
+
options?: QueryOptions,
|
|
152
|
+
callback?: (err: Error, results: any) => void
|
|
153
|
+
): any;
|
|
154
|
+
stream(options?: any): NodeJS.ReadableStream;
|
|
155
|
+
|
|
156
|
+
startTimer(): Profiler;
|
|
157
|
+
profile(id: string | number, meta?: Record<string, any>): this;
|
|
158
|
+
|
|
159
|
+
configure(options: LoggerOptions): void;
|
|
160
|
+
|
|
161
|
+
child(options: Object): this;
|
|
162
|
+
|
|
163
|
+
isLevelEnabled(level: string): boolean;
|
|
164
|
+
isErrorEnabled(): boolean;
|
|
165
|
+
isWarnEnabled(): boolean;
|
|
166
|
+
isInfoEnabled(): boolean;
|
|
167
|
+
isVerboseEnabled(): boolean;
|
|
168
|
+
isDebugEnabled(): boolean;
|
|
169
|
+
isSillyEnabled(): boolean;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
class Container {
|
|
173
|
+
loggers: Map<string, Logger>;
|
|
174
|
+
options: LoggerOptions;
|
|
175
|
+
|
|
176
|
+
add(id: string, options?: LoggerOptions): Logger;
|
|
177
|
+
get(id: string, options?: LoggerOptions): Logger;
|
|
178
|
+
has(id: string): boolean;
|
|
179
|
+
close(id?: string): void;
|
|
180
|
+
|
|
181
|
+
constructor(options?: LoggerOptions);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
let version: string;
|
|
185
|
+
let loggers: Container;
|
|
186
|
+
|
|
187
|
+
let addColors: (target: Config.AbstractConfigSetColors) => any;
|
|
188
|
+
let createLogger: (options?: LoggerOptions) => Logger;
|
|
189
|
+
|
|
190
|
+
// Pass-through npm level methods routed to the default logger.
|
|
191
|
+
let error: LeveledLogMethod;
|
|
192
|
+
let warn: LeveledLogMethod;
|
|
193
|
+
let info: LeveledLogMethod;
|
|
194
|
+
let http: LeveledLogMethod;
|
|
195
|
+
let verbose: LeveledLogMethod;
|
|
196
|
+
let debug: LeveledLogMethod;
|
|
197
|
+
let silly: LeveledLogMethod;
|
|
198
|
+
|
|
199
|
+
// Other pass-through methods routed to the default logger.
|
|
200
|
+
let log: LogMethod;
|
|
201
|
+
let query: (
|
|
202
|
+
options?: QueryOptions,
|
|
203
|
+
callback?: (err: Error, results: any) => void
|
|
204
|
+
) => any;
|
|
205
|
+
let stream: (options?: any) => NodeJS.ReadableStream;
|
|
206
|
+
let add: (transport: Transport) => Logger;
|
|
207
|
+
let remove: (transport: Transport) => Logger;
|
|
208
|
+
let clear: () => Logger;
|
|
209
|
+
let startTimer: () => Profiler;
|
|
210
|
+
let profile: (id: string | number) => Logger;
|
|
211
|
+
let configure: (options: LoggerOptions) => void;
|
|
212
|
+
let child: (options: Object) => Logger;
|
|
213
|
+
let level: string;
|
|
214
|
+
let exceptions: ExceptionHandler;
|
|
215
|
+
let rejections: RejectionHandler;
|
|
216
|
+
let exitOnError: Function | boolean;
|
|
217
|
+
// let default: object;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export = winston;
|