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

fix(log): ensure consistent behavior with @std/log #5974

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

iuioiua
Copy link
Collaborator

@iuioiua iuioiua commented Sep 13, 2024

Fixes #5972

@iuioiua iuioiua requested a review from kt3k as a code owner September 13, 2024 01:21
@github-actions github-actions bot added the log label Sep 13, 2024
Copy link
Collaborator Author

@iuioiua iuioiua Sep 13, 2024

Choose a reason for hiding this comment

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

This test is failing because debug() doesn't actually print to the console for some reason. Need to figure out why... Any ideas, @kt3k?

Copy link
Member

Choose a reason for hiding this comment

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

I think you need to call setup and override the default log level to DEBUG like the below:

import * as log from "@std/log";
log.setup({
  handlers: {
    default: new log.ConsoleHandler("DEBUG"),
  },  
  loggers: {
    default: {
      level: "DEBUG",
      handlers: ["default"],
    }   
  }
});
log.debug("debug");

The default log level is set to "INFO" here

export const DEFAULT_LEVEL = "INFO";

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are you suggesting we add that to log/debug.ts? What is the expected behavior of the following script?

import { debug } from "@std/log/debug";

debug("Hello, world!");

Copy link
Member

Choose a reason for hiding this comment

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

I think the expected behavior is noop because the default log level is not low enough to log DEBUG log.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug(log): warn() and others behave different depending on import
2 participants