Skip to content

docs: added custom logger info#10108

Merged
patak-cat merged 5 commits intovitejs:mainfrom
g4rry420:issue_9597
Feb 24, 2023
Merged

docs: added custom logger info#10108
patak-cat merged 5 commits intovitejs:mainfrom
g4rry420:issue_9597

Conversation

@g4rry420
Copy link
Contributor

@g4rry420 g4rry420 commented Sep 14, 2022

Signed-off-by: GurkiranSingh gurkiransinghk@gmail.com

Description

Added the information about Custom Logger. Please, let me know if you see any errors :)
Resolves #9597

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Signed-off-by: GurkiranSingh <gurkiransinghk@gmail.com>
@sapphi-red sapphi-red changed the title docs: Added Custom Logger info docs: added custom logger info Sep 18, 2022
@sapphi-red sapphi-red added the documentation Improvements or additions to documentation label Sep 18, 2022
sapphi-red
sapphi-red previously approved these changes Sep 18, 2022
Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@patak-cat
Copy link
Member

Thanks for the PR @g4rry420! @antfu exposed the logger so the community could reuse it. Maybe we could document changing the prefix instead? (see original PR #2019)
If we want to promote the use case described in this docs addition I wonder if we should extend before createLogger APIs to make this scheme easier.

@g4rry420
Copy link
Contributor Author

@patak-dev What do you think of this example ?

import { createLogger, defineConfig } from 'vite';

const logger = createLogger("warn", { prefix: "[VITE-WARNING]", allowClearScreen: false });
const originalWarning = logger.warn;
logger.warn = (msg, options) => {
  if (msg.includes('vite:css') && msg.includes(' is empty')) return;
  originalWarning(msg, options);
};

export default defineConfig({
  customLoger: logger,
});

@bluwy
Copy link
Member

bluwy commented Feb 24, 2023

I think it's fine to document this for now even with it's slightly un-ergonomic API to customize it so that others know how to filter out certain warnings.

I've also moved it as a config options docs instead which I think is a bit more fitting, but happy to discuss further too.

@patak-cat patak-cat merged commit 8477b07 into vitejs:main Feb 24, 2023
@g4rry420 g4rry420 deleted the issue_9597 branch February 24, 2023 08:51
futurGH pushed a commit to futurGH/vite that referenced this pull request Feb 26, 2023
Co-authored-by: 翠 / green <green@sapphi.red>
Co-authored-by: bluwy <bjornlu.dev@gmail.com>
@bluwy bluwy mentioned this pull request Apr 1, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add an option to ignore postcss warnings

4 participants