-
Notifications
You must be signed in to change notification settings - Fork 13.5k
/
Copy pathindex.ts
39 lines (36 loc) · 1.42 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { config } from '@global/config';
/**
* Logs a warning to the console with an Ionic prefix
* to indicate the library that is warning the developer.
*
* @param message - The string message to be logged to the console.
*/
export const printIonWarning = (message: string, ...params: any[]) => {
const logLevel = config.get('logLevel', 'WARN');
if (['WARN'].includes(logLevel)) {
return console.warn(`[Ionic Warn]: ${message}`, ...params);
}
};
/*
* Logs an error to the console with an Ionic prefix
* to indicate the library that is warning the developer.
*
* @param message - The string message to be logged to the console.
* @param params - Additional arguments to supply to the console.error.
*/
export const printIonError = (message: string, ...params: any[]) => {
const logLevel = config.get('logLevel', 'ERROR');
if (['ERROR', 'WARN'].includes(logLevel)) {
return console.error(`[Ionic Error]: ${message}`, ...params);
}
};
/**
* Prints an error informing developers that an implementation requires an element to be used
* within a specific selector.
*
* @param el The web component element this is requiring the element.
* @param targetSelectors The selector or selectors that were not found.
*/
export const printRequiredElementError = (el: HTMLElement, ...targetSelectors: string[]) => {
return console.error(`<${el.tagName.toLowerCase()}> must be used inside ${targetSelectors.join(' or ')}.`);
};