Socket
Socket
Sign inDemoInstall

@docusaurus/logger

Package Overview
Dependencies
2
Maintainers
6
Versions
983
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@docusaurus/logger


Version published
Maintainers
6
Install size
286 kB
Created

Package description

What is @docusaurus/logger?

@docusaurus/logger is a logging utility designed for use with Docusaurus, a popular static site generator. It provides a simple and consistent way to log messages with different levels of severity, such as info, warn, error, and success. The package is useful for developers who need to output logs during the build process or while running scripts related to Docusaurus projects.

What are @docusaurus/logger's main functionalities?

Info Logging

Logs an informational message. This is useful for general-purpose logging to inform the user about the progress or state of the application.

const logger = require('@docusaurus/logger');
logger.info('This is an info message');

Warning Logging

Logs a warning message. This is useful for indicating potential issues that are not critical but should be noted.

const logger = require('@docusaurus/logger');
logger.warn('This is a warning message');

Error Logging

Logs an error message. This is useful for reporting errors that occur during the execution of the application.

const logger = require('@docusaurus/logger');
logger.error('This is an error message');

Success Logging

Logs a success message. This is useful for indicating successful completion of tasks or operations.

const logger = require('@docusaurus/logger');
logger.success('This is a success message');

Other packages similar to @docusaurus/logger

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.
  • Formatters. These functions have the same signature as the formatters of picocolors. Note that their implementations are not guaranteed. You should only care about their semantics.
    • path: formats a file path or URL.
    • id: 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.
  • Logging functions. All logging functions can both be used as functions (in which it has the same usage as console.log) or template literal tags.
    • info: prints information.
    • warn: prints a warning that should be payed attention to.
    • error: prints an error (not necessarily halting the program) that signals significant problems.
    • success: prints a success message.

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:

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 percentage sign followed by a few lowercase letters). If it's not preceded by any flag, it's printed out as-is. Otherwise, it's formatted with one of the formatters:

  • path=: path
  • name=: id
  • 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:

demo

FAQs

Last updated on 07 Jan 2022

Did you know?

Socket

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc