1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.createLogLevelDiagLogger = void 0;
|
19 | const types_1 = require("../types");
|
20 | function createLogLevelDiagLogger(maxLevel, logger) {
|
21 | if (maxLevel < types_1.DiagLogLevel.NONE) {
|
22 | maxLevel = types_1.DiagLogLevel.NONE;
|
23 | }
|
24 | else if (maxLevel > types_1.DiagLogLevel.ALL) {
|
25 | maxLevel = types_1.DiagLogLevel.ALL;
|
26 | }
|
27 |
|
28 | logger = logger || {};
|
29 | function _filterFunc(funcName, theLevel) {
|
30 | const theFunc = logger[funcName];
|
31 | if (typeof theFunc === 'function' && maxLevel >= theLevel) {
|
32 | return theFunc.bind(logger);
|
33 | }
|
34 | return function () { };
|
35 | }
|
36 | return {
|
37 | error: _filterFunc('error', types_1.DiagLogLevel.ERROR),
|
38 | warn: _filterFunc('warn', types_1.DiagLogLevel.WARN),
|
39 | info: _filterFunc('info', types_1.DiagLogLevel.INFO),
|
40 | debug: _filterFunc('debug', types_1.DiagLogLevel.DEBUG),
|
41 | verbose: _filterFunc('verbose', types_1.DiagLogLevel.VERBOSE),
|
42 | };
|
43 | }
|
44 | exports.createLogLevelDiagLogger = createLogLevelDiagLogger;
|
45 |
|
\ | No newline at end of file |