diff --git a/packages/logger/src/logger.ts b/packages/logger/src/logger.ts index b190729e..0ec8cb61 100644 --- a/packages/logger/src/logger.ts +++ b/packages/logger/src/logger.ts @@ -84,10 +84,15 @@ export const createLogger = (domain: string, devMode = DEV_MODE): AlwatrLogger = /** * Required logger object, accident, error always reported even when the devMode is false. */ - const requiredItems = { + const requiredItems: AlwatrLogger = { devMode, domain, + banner: NODE_MODE + ? console.log.bind(console, `\x1b[1;37;45m\n\n %s${_style.reset}`) + : console.log.bind(console, '%c%s', + 'font-size: 2rem; background-color: #5858e8; color: #fff; padding: 1rem 4rem; border-radius: 0.5rem;'), + accident: NODE_MODE ? console.warn.bind(console, `${styleScope}⚠️\n%s\x1b[33m.%s() Accident \`%s\` %s!${_style.reset}`, domain) : console.warn.bind(console, '%c%s%c.%s() Accident `%s` %s!', styleScope, domain, _style.reset), @@ -95,7 +100,7 @@ export const createLogger = (domain: string, devMode = DEV_MODE): AlwatrLogger = error: NODE_MODE ? console.error.bind(console, `${styleScope}❌\n%s\x1b[31m.%s() Error \`%s\`${_style.reset}\n`, domain) : console.error.bind(console, '%c%s%c.%s() Error `%s`\n', styleScope, domain, _style.reset), - } as const; + }; if (!devMode) { return requiredItems; diff --git a/packages/logger/src/type.ts b/packages/logger/src/type.ts index 32455e5a..371fd24a 100644 --- a/packages/logger/src/type.ts +++ b/packages/logger/src/type.ts @@ -143,4 +143,15 @@ export interface AlwatrLogger { * ``` */ timeEnd?(label: string): void; + + /** + * log big banner + * + * Example: + * + * ```ts + * logger.banner('Alwatr PWA v2'); + * ``` + */ + banner?(message: string): void; }