1 | /*
|
2 | * Copyright The OpenTelemetry Authors
|
3 | *
|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | * you may not use this file except in compliance with the License.
|
6 | * You may obtain a copy of the License at
|
7 | *
|
8 | * https://www.apache.org/licenses/LICENSE-2.0
|
9 | *
|
10 | * Unless required by applicable law or agreed to in writing, software
|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | * See the License for the specific language governing permissions and
|
14 | * limitations under the License.
|
15 | */
|
16 | var consoleMap = [
|
17 | { n: 'error', c: 'error' },
|
18 | { n: 'warn', c: 'warn' },
|
19 | { n: 'info', c: 'info' },
|
20 | { n: 'debug', c: 'debug' },
|
21 | { n: 'verbose', c: 'trace' },
|
22 | ];
|
23 | /**
|
24 | * A simple Immutable Console based diagnostic logger which will output any messages to the Console.
|
25 | * If you want to limit the amount of logging to a specific level or lower use the
|
26 | * {@link createLogLevelDiagLogger}
|
27 | */
|
28 | var DiagConsoleLogger = /** @class */ (function () {
|
29 | function DiagConsoleLogger() {
|
30 | function _consoleFunc(funcName) {
|
31 | return function () {
|
32 | var args = [];
|
33 | for (var _i = 0; _i < arguments.length; _i++) {
|
34 | args[_i] = arguments[_i];
|
35 | }
|
36 | if (console) {
|
37 | // Some environments only expose the console when the F12 developer console is open
|
38 | // eslint-disable-next-line no-console
|
39 | var theFunc = console[funcName];
|
40 | if (typeof theFunc !== 'function') {
|
41 | // Not all environments support all functions
|
42 | // eslint-disable-next-line no-console
|
43 | theFunc = console.log;
|
44 | }
|
45 | // One last final check
|
46 | if (typeof theFunc === 'function') {
|
47 | return theFunc.apply(console, args);
|
48 | }
|
49 | }
|
50 | };
|
51 | }
|
52 | for (var i = 0; i < consoleMap.length; i++) {
|
53 | this[consoleMap[i].n] = _consoleFunc(consoleMap[i].c);
|
54 | }
|
55 | }
|
56 | return DiagConsoleLogger;
|
57 | }());
|
58 | export { DiagConsoleLogger };
|
59 | //# sourceMappingURL=consoleLogger.js.map |
\ | No newline at end of file |