-
-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows to control the level of logs with `CONSOLA_LEVEL=5 pnpm run dev`
- Loading branch information
Showing
13 changed files
with
118 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { defineBuildConfig } from 'unbuild' | ||
|
||
export default defineBuildConfig({ | ||
// explicitly externalize consola since Nuxt has it | ||
externals: ['consola'], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,19 @@ | ||
export type LogType = 'debug' | 'info' | 'warn' | 'error' | 'trace' | 'log' | ||
import { consola as consolaBase } from 'consola' | ||
export type { LogType } from 'consola' | ||
|
||
// TODO: allow disabling logs with some env variables | ||
const nuxtVueFireConsola = consolaBase.withTag('nuxt-vuefire') | ||
|
||
export function log(type: LogType, ...args: any[]): void | ||
export function log(...args: any[]): void | ||
export function log(...args: unknown[]): void { | ||
const [typeOrLog, ...rest] = args | ||
if (isLogType(typeOrLog)) { | ||
console[typeOrLog]('[nuxt-vuefire]:', ...rest) | ||
} else { | ||
console.log('[nuxt-vuefire]:', ...args) | ||
} | ||
} | ||
export { nuxtVueFireConsola as logger } | ||
|
||
function isLogType(logType: unknown): logType is LogType { | ||
return ( | ||
logType === 'debug' || | ||
logType === 'info' || | ||
logType === 'warn' || | ||
logType === 'error' || | ||
logType === 'trace' | ||
) | ||
} | ||
// run this to have more levels of logging | ||
// https://github.com/unjs/consola#log-level | ||
// CONSOLA_LEVEL=5 nr dev | ||
|
||
// NOTE: used to test | ||
// nuxtVueFireConsola.trace('trace', 'i am a test') | ||
// nuxtVueFireConsola.debug('debug', 'i am a test') | ||
// nuxtVueFireConsola.log('log', 'i am a test') | ||
// nuxtVueFireConsola.info('info', 'i am a test') | ||
// nuxtVueFireConsola.success('success', 'i am a test') | ||
// nuxtVueFireConsola.warn('warn', 'i am a test') | ||
// nuxtVueFireConsola.error('error', 'i am a test', new Error('haha')) |
Oops, something went wrong.