-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
client.js
42 lines (36 loc) · 989 Bytes
/
client.js
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
import { Logger } from 'meteor/ostrio:logger';
import { check, Match } from 'meteor/check';
const NOOP = () => {};
/**
* @class LoggerFile
* @summary File (FS) adapter for ostrio:logger (Logger)
*/
class LoggerFile {
constructor(logger, options = {}) {
check(logger, Match.OneOf(Logger, Object));
check(options, Match.Optional(Object));
this.logger = logger;
this.options = options;
this.logger.add('File', NOOP, NOOP, false, false);
}
enable(rule = {}) {
check(rule, {
enable: Match.Optional(Boolean),
client: Match.Optional(Boolean),
server: Match.Optional(Boolean),
filter: Match.Optional([String])
});
if (typeof rule.enable === 'undefined') {
rule.enable = true;
}
if (typeof rule.client === 'undefined') {
rule.client = true;
}
if (typeof rule.server === 'undefined') {
rule.server = true;
}
this.logger.rule('File', rule);
return this;
}
}
export { LoggerFile };