Total Complexity | 8 |
Complexity/F | 1.33 |
Lines of Code | 41 |
Function Count | 6 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | /*eslint no-unused-expressions: 0*/ |
||
4 | import { isUndefined } from 'lodash'; |
||
5 | |||
6 | if (isUndefined(IS_LOGGING)) { |
||
|
|||
7 | throw new Error('IS_LOGGING must be set.'); |
||
8 | } |
||
9 | |||
10 | if (isUndefined(LOGGING_LEVEL)) { |
||
11 | throw new Error('LOGGING_LEVEL must be set.'); |
||
12 | } |
||
13 | |||
14 | export const LogLevels = { |
||
15 | LOG: 1, |
||
16 | INFO: 2, |
||
17 | WARN: 3, |
||
18 | ERROR: 4, |
||
19 | DEBUG: 5 |
||
20 | }; |
||
21 | |||
22 | export function log() { |
||
23 | shouldLog(LogLevels.LOG) && console.log.apply(console, arguments); |
||
24 | } |
||
25 | |||
26 | export function info() { |
||
27 | shouldLog(LogLevels.INFO) && console.info.apply(console, arguments); |
||
28 | } |
||
29 | |||
30 | export function warn() { |
||
31 | shouldLog(LogLevels.WARN) && console.warn.apply(console, arguments); |
||
32 | } |
||
33 | |||
34 | export function error() { |
||
35 | shouldLog(LogLevels.ERROR) && console.error.apply(console, arguments); |
||
36 | } |
||
37 | |||
38 | export function debug() { |
||
39 | shouldLog(LogLevels.DEBUG) && console.debug.apply(console, arguments); |
||
40 | } |
||
41 | |||
42 | function shouldLog(logLevel) { |
||
43 | return Boolean(IS_LOGGING) && LOGGING_LEVEL >= logLevel; |
||
44 | } |
||
45 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.