mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-29 17:07:22 +00:00
f26a801775
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Daniel Roe <daniel@roe.dev>
46 lines
975 B
Markdown
46 lines
975 B
Markdown
---
|
|
title: "Logging"
|
|
description: Nuxt Kit provides a set of utilities to help you work with logging. These functions allow you to log messages with extra features.
|
|
links:
|
|
- label: Source
|
|
icon: i-simple-icons-github
|
|
to: https://github.com/nuxt/nuxt/blob/main/packages/kit/src/logger.ts
|
|
size: xs
|
|
---
|
|
|
|
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](https://github.com/unjs/consola) under the hood.
|
|
|
|
### Type
|
|
|
|
```ts
|
|
function useLogger (tag?: string): ConsolaInstance
|
|
```
|
|
|
|
### Parameters
|
|
|
|
#### `tag`
|
|
|
|
**Type**: `string`
|
|
|
|
***Optional**: `true`
|
|
|
|
A tag to prefix all log messages with.
|
|
|
|
### Examples
|
|
|
|
```ts
|
|
import { defineNuxtModule, useLogger } from '@nuxt/kit'
|
|
|
|
export default defineNuxtModule({
|
|
setup(options, nuxt) {
|
|
const logger = useLogger('my-module')
|
|
|
|
logger.info('Hello from my module!')
|
|
}
|
|
})
|
|
```
|