/
githubmirror
/
ionic
Обзор
Документация
Войти
/
githubmirror
/
ionic
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
core/src/utils/logging/index.ts
45 строк
2 KB
Brandy Smith
fix(config): allow LogLevel to work with isolatedModules and update all warns and errors to respect logLevel (#30350)
16 апр 2025, 19:23
Не верифицирован
16 апр 2025, 19:23
d52fca0
Код
Авторство
О чём код?
import { config } from '@global/config'; export enum LogLevel { OFF = 'OFF', ERROR = 'ERROR', WARN = 'WARN', } /** * 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', LogLevel.WARN); if ([LogLevel.WARN].includes(logLevel)) { return console.warn(`[Ionic Warning]: ${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', LogLevel.ERROR); if ([LogLevel.ERROR, LogLevel.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 ')}.`); };