|
1 | 1 | import { config } from '@global/config'; |
2 | 2 |
|
| 3 | +export const enum LogLevel { |
| 4 | + INFO = 'INFO', |
| 5 | + ERROR = 'ERROR', |
| 6 | + WARN = 'WARN', |
| 7 | +} |
| 8 | + |
3 | 9 | /** |
4 | 10 | * Logs a warning to the console with an Ionic prefix |
5 | 11 | * to indicate the library that is warning the developer. |
6 | 12 | * |
7 | 13 | * @param message - The string message to be logged to the console. |
8 | 14 | */ |
9 | 15 | export const printIonWarning = (message: string, ...params: any[]) => { |
10 | | - const logLevel = config.get('logLevel', 'WARN'); |
11 | | - if (['WARN'].includes(logLevel)) { |
| 16 | + const logLevel = config.get('logLevel', LogLevel.WARN); |
| 17 | + if ([LogLevel.WARN].includes(logLevel)) { |
12 | 18 | return console.warn(`[Ionic Warning]: ${message}`, ...params); |
13 | 19 | } |
14 | 20 | }; |
15 | 21 |
|
16 | | -/* |
| 22 | +/** |
17 | 23 | * Logs an error to the console with an Ionic prefix |
18 | 24 | * to indicate the library that is warning the developer. |
19 | 25 | * |
20 | 26 | * @param message - The string message to be logged to the console. |
21 | 27 | * @param params - Additional arguments to supply to the console.error. |
22 | 28 | */ |
23 | 29 | export const printIonError = (message: string, ...params: any[]) => { |
24 | | - const logLevel = config.get('logLevel', 'ERROR'); |
25 | | - if (['ERROR', 'WARN'].includes(logLevel)) { |
| 30 | + const logLevel = config.get('logLevel', LogLevel.ERROR); |
| 31 | + if ([LogLevel.ERROR, LogLevel.WARN].includes(logLevel)) { |
26 | 32 | return console.error(`[Ionic Error]: ${message}`, ...params); |
27 | 33 | } |
28 | 34 | }; |
|
0 commit comments