Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat: shared logger and silent test logs #3259

Merged
merged 6 commits into from
Feb 16, 2022
Merged

feat: shared logger and silent test logs #3259

merged 6 commits into from
Feb 16, 2022

Conversation

antfu
Copy link
Member

@antfu antfu commented Feb 16, 2022

πŸ”— Linked issue

nuxt/nuxt#13372

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Introduce logger and useLogger exports from @nuxt/kit:

import { logger, useLogger } from '@nuxt/kit'

However consola is globally registered, this allows more semantic usage also removed the need for module authors to add another consola dependency when they want to create a namespace logger

This PR also introduces the logLevel option to @nuxt/test-utils defaulting to 1 which will be auto silent to the warning in the test environment. This option updates level of kit logger.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@netlify
Copy link

netlify bot commented Feb 16, 2022

βœ”οΈ Deploy Preview for nuxt3-docs canceled.

πŸ”¨ Explore the source changes: d98af6e

πŸ” Inspect the deploy log: https://app.netlify.com/sites/nuxt3-docs/deploys/620d6bc23db60e0009f21a1c

@pi0
Copy link
Member

pi0 commented Feb 16, 2022

Love the idea of a shared logger! Although consola has a take-over mode that we use in nuxt 2 cli and nuxi. I think it is a great idea to explicitly use it from nuxt instead of importing from consola. What do you think if we introduce useLogger from @nuxt/kit? (we could use it for example to also have namespace loggers like useLogger('my-module'))

Upstream improvement to apply level to all console usages: unjs/consola#131

@pi0 pi0 changed the title feat: new logLevel options feat: useLogger Feb 16, 2022
@pi0 pi0 assigned pi0 and antfu Feb 16, 2022
@pi0 pi0 changed the title feat: useLogger feat: shared logger and silent test logs Feb 16, 2022
@pi0 pi0 mentioned this pull request Feb 16, 2022
11 tasks
@pi0 pi0 merged commit 467ab69 into main Feb 16, 2022
@pi0 pi0 deleted the feat/slient branch February 16, 2022 21:34
@danielroe danielroe added the 3.x label Jan 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants