Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(common): In case of an expensive log, allow to pass a function #11281

Merged
merged 1 commit into from
Mar 22, 2023

Commits on Mar 14, 2023

  1. perf(common): In case of an expensive log, allow to pass a function

    In certain case, it is very expensive to log some values. Instead of
    checking if certain level is enabled, allow the users to pass in a
    function that is only called if we need to stringify the log value.
    
    This keeps the API small, while still allowing expensive logging to
    be called when needed, and skipped when not.
    
    e.g. instead of
    
    ```javascript
    // This check is technically done twice.
    if (this.logger.isLevelEnabled('debug')) {
      this.logger.debug(this.generateAsciiArtFromJpeg());
    }
    ```
    
    the customer could use:
    
    ```javascript
    this.logger.debug(() => this.generateAsciiArtFromJpeg());
    ```
    hansl committed Mar 14, 2023
    Configuration menu
    Copy the full SHA
    618bcc4 View commit details
    Browse the repository at this point in the history