mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 10:04:05 +00:00
1.3 KiB
1.3 KiB
title | description | links | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Logging | Nuxt Kit provides a set of utilities to help you work with logging. These functions allow you to log messages with extra features. |
|
Nuxt provides a logger instance that you can use to log messages with extra features. useLogger
allows you to get a logger instance.
useLogger
Returns a logger instance. It uses consola under the hood.
Type
function useLogger (tag?: string, options?: Partial<ConsolaOptions>): ConsolaInstance
Parameters
tag
Type: string
*Optional: true
A tag to prefix all log messages with.
options
Type: Partial<ConsolaOptions>
*Optional: true
Consola configuration options
Examples
import { defineNuxtModule, useLogger } from '@nuxt/kit'
export default defineNuxtModule({
setup(options, nuxt) {
const logger = useLogger('my-module')
logger.info('Hello from my module!')
}
})
import { defineNuxtModule, useLogger } from '@nuxt/kit'
export default defineNuxtModule({
setup(options, nuxt) {
const logger = useLogger('my-module', { level: options.quiet ? 0 : 3 })
logger.info('Hello from my module!')
}
})