Socket
Socket
Sign inDemoInstall

@docusaurus/logger

Package Overview
Dependencies
7
Maintainers
4
Versions
961
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @docusaurus/logger

An encapsulated logger for semantically formatting console messages.


Version published
Maintainers
4
Install size
296 kB
Created

Changelog

Source

3.3.0 (2024-05-03)

:rocket: New Feature
  • docusaurus-plugin-sitemap
    • #10083 feat: add createSitemapItems hook (@johnnyreilly)
  • docusaurus-mdx-loader, docusaurus-types, docusaurus
    • #10064 feat(core): add new site config option siteConfig.markdown.anchors.maintainCase (@iAdramelk)
  • docusaurus
    • #9767 feat(cli): docusaurus deploy should support a --target-dir option (@SandPod)
  • docusaurus-plugin-content-blog, docusaurus-plugin-content-docs, docusaurus-plugin-content-pages, docusaurus-plugin-debug, docusaurus-types, docusaurus
    • #10042 feat(core): simplify plugin API, support route.props (@slorber)
  • docusaurus-plugin-content-pages, docusaurus-theme-classic, docusaurus-theme-common
    • #10032 feat(pages): add LastUpdateAuthor & LastUpdateTime & editUrl (@OzakIOne)
:bug: Bug Fix
  • docusaurus-cssnano-preset, docusaurus-utils, docusaurus
  • docusaurus-theme-classic
    • #10091 fix(theme): <Tabs> props should allow overriding defaults (@gagdiez)
    • #10080 fix(theme): <Admonition> should render properly without heading/icon (@andrmaz)
  • docusaurus
    • #10090 fix(core): docusaurus serve redirects should include the site /baseUrl/ prefix (@slorber)
  • docusaurus-module-type-aliases, docusaurus-preset-classic, docusaurus-theme-classic, docusaurus-theme-live-codeblock, docusaurus
  • docusaurus-theme-translations
    • #10070 fix(theme-translations): add missing theme translations for pt-BR (@h3nr1ke)
    • #10051 fix(theme-translations): correct label for tip admonition in italian (@tomsotte)
  • docusaurus-theme-search-algolia
    • #10048 fix(algolia): add insights property on Algolia Theme Config object TS definition (@Virgil993)
  • docusaurus-plugin-content-docs, docusaurus
    • #10054 fix(core): sortRoutes shouldn't have a default baseUrl value, this led to a bug (@slorber)
  • docusaurus-plugin-content-docs
  • docusaurus-utils
    • #10022 fix(utils): getFileCommitDate should support log.showSignature=true (@slorber)
:running_woman: Performance
  • docusaurus
    • #10060 refactor(core): optimize App entrypoint, it should not re-render when navigating (@slorber)
:nail_care: Polish
  • docusaurus-theme-classic
    • #10061 refactor(theme): simplify CSS solution to solve empty search container (@slorber)
  • docusaurus-theme-common
:memo: Documentation
:robot: Dependencies
:wrench: Maintenance
  • create-docusaurus, docusaurus-cssnano-preset, docusaurus-logger, docusaurus-mdx-loader, docusaurus-plugin-client-redirects, docusaurus-plugin-content-blog, docusaurus-plugin-content-docs, docusaurus-plugin-content-pages, docusaurus-plugin-debug, docusaurus-plugin-google-analytics, docusaurus-plugin-google-gtag, docusaurus-plugin-google-tag-manager, docusaurus-plugin-ideal-image, docusaurus-plugin-pwa, docusaurus-plugin-sitemap, docusaurus-plugin-vercel-analytics, docusaurus-preset-classic, docusaurus-remark-plugin-npm2yarn, docusaurus-theme-classic, docusaurus-theme-common, docusaurus-theme-live-codeblock, docusaurus-theme-mermaid, docusaurus-theme-search-algolia, docusaurus-theme-translations, docusaurus-utils-common, docusaurus-utils-validation, docusaurus-utils, docusaurus, eslint-plugin, lqip-loader, stylelint-copyright
    • #10065 refactor: extract base TS client config + upgrade TS + refactor TS setup (@slorber)
  • Other
    • #10063 test(e2e): TypeCheck website/starter in min/max range of TS versions (@slorber)
    • #10049 fix(website): fix website manifest.json name "Docusaurus v2" to just "Docusaurus" (@volcanofr)
Committers: 20

Readme

Source

@docusaurus/logger

An encapsulated logger for semantically formatting console messages.

APIs

It exports a single object as default export: logger. logger has the following properties:

  • Some useful colors.
    • red
    • yellow
    • green
    • bold
    • dim
  • Formatters. These functions all have the signature (msg: unknown) => string. Note that their implementations are not guaranteed. You should only care about their semantics.
    • path: formats a file path.
    • url: formats a URL.
    • name: formats an identifier.
    • code: formats a code snippet.
    • subdue: subdues the text.
    • num: formats a number.
  • The interpolate function. It is a template literal tag. The syntax can be found below.
  • Logging functions. All logging functions can both be used as normal functions (similar to the console.log family, but only accepts one parameter) or template literal tags.
    • info: prints information.
    • warn: prints a warning that should be paid attention to.
    • error: prints an error (not necessarily halting the program) that signals significant problems.
    • success: prints a success message.
  • The report function. It takes a ReportingSeverity value (ignore, log, warn, throw) and reports a message according to the severity.

A word on the error formatter

Beware that an error message, even when it doesn't hang the program, is likely going to cause confusion. When users inspect logs and find an [ERROR], even when the build succeeds, they will assume something is going wrong. Use it sparingly.

Docusaurus only uses logger.error when printing messages immediately before throwing an error, or when user has set the reporting severity of onBrokenLink, etc. to "error".

In addition, warn and error will color the entire message for better attention. If you are printing large blocks of help text about an error, better use logger.info.

Using the template literal tag

The template literal tag evaluates the template and expressions embedded. interpolate returns a new string, while other logging functions prints it. Below is a typical usage:

import logger from '@docusaurus/logger';

logger.info`Hello name=${name}! You have number=${money} dollars. Here are the ${
  items.length > 1 ? 'items' : 'item'
} on the shelf: ${items}
To buy anything, enter code=${'buy x'} where code=${'x'} is the item's name; to quit, press code=${'Ctrl + C'}.`;

An embedded expression is optionally preceded by a flag in the form [a-z]+= (a few lowercase letters, followed by an equals sign, directly preceding the embedded expression). If the expression is not preceded by any flag, it's printed out as-is. Otherwise, it's formatted with one of the formatters:

  • path=: path
  • url=: url
  • name=: name
  • code=: code
  • subdue=: subdue
  • number=: num

If the expression is an array, it's formatted by `\n- ${array.join('\n- ')}\n` (note it automatically gets a leading line end). Each member is formatted by itself and the bullet is not formatted. So you would see the above message printed as:

Some text output in the terminal, containing array, code, name, and number formatting

FAQs

Last updated on 03 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc