diff options
Diffstat (limited to 'packages/main/src/utils')
-rw-r--r-- | packages/main/src/utils/getLogger.ts (renamed from packages/main/src/utils/log.ts) | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/packages/main/src/utils/log.ts b/packages/main/src/utils/getLogger.ts index d9748f4..7ed38de 100644 --- a/packages/main/src/utils/log.ts +++ b/packages/main/src/utils/getLogger.ts | |||
@@ -23,10 +23,16 @@ import chalk, { ChalkInstance } from 'chalk'; | |||
23 | import loglevel from 'loglevel'; | 23 | import loglevel from 'loglevel'; |
24 | import prefix from 'loglevel-plugin-prefix'; | 24 | import prefix from 'loglevel-plugin-prefix'; |
25 | 25 | ||
26 | if (import.meta.env?.DEV) { | 26 | switch (import.meta.env.MODE) { |
27 | loglevel.setLevel('debug'); | 27 | case 'development': |
28 | } else { | 28 | loglevel.setLevel('debug', false); |
29 | loglevel.setLevel('info'); | 29 | break; |
30 | case 'test': | ||
31 | loglevel.setLevel('silent', false); | ||
32 | break; | ||
33 | default: | ||
34 | loglevel.setLevel('info', false); | ||
35 | break; | ||
30 | } | 36 | } |
31 | 37 | ||
32 | const COLORS: Map<string, ChalkInstance> = new Map([ | 38 | const COLORS: Map<string, ChalkInstance> = new Map([ |
@@ -51,14 +57,6 @@ prefix.apply(loglevel, { | |||
51 | }, | 57 | }, |
52 | }); | 58 | }); |
53 | 59 | ||
54 | export function getLogger(loggerName: string): loglevel.Logger { | 60 | export default function getLogger(loggerName: string): loglevel.Logger { |
55 | return loglevel.getLogger(loggerName); | 61 | return loglevel.getLogger(loggerName); |
56 | } | 62 | } |
57 | |||
58 | export function silenceLogger(): void { | ||
59 | loglevel.disableAll(); | ||
60 | const loggers = loglevel.getLoggers(); | ||
61 | Object.values(loggers).forEach((logger) => { | ||
62 | logger.disableAll(); | ||
63 | }); | ||
64 | } | ||