Logging
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): ConsolaInstance
Parameters
tag
Type: string
*Optional: true
A tag to prefix all log messages with.
Examples
import { defineNuxtModule, useLogger } from '@nuxt/kit'
export default defineNuxtModule({
setup(options, nuxt) {
const logger = useLogger('my-module')
logger.info('Hello from my module!')
}
})