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: use noop logger by default #159

Merged
merged 1 commit into from
Jan 13, 2024

Conversation

iskorotkov
Copy link
Contributor

Changes:

  • added interface Logger
  • added global variable logger
  • added method to change global logger
  • replaced all log package references with logger global variable
  • use noop logger by default

Reasoning:

  • correct me if I'm wrong, current implementation prints debug data every time certain function is run. This simple PR disables all logging by default, but library users can supply their own logger and turn logging back on.

The solution isn't very flexible or configurable as I tried to keep it as simple as possible.

Comment on lines -127 to +126
log.Println("interrupt")
logger.Println("interrupt")
Copy link
Owner

Choose a reason for hiding this comment

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

Since the logs are not set from the user's point of view, but from the developer's point of view, it seems okay to default to no log output 👍

Comment on lines +8 to +10
type Logger interface {
Println(values ...any)
}
Copy link
Owner

Choose a reason for hiding this comment

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

💭 As you said, this interface may need improvement.

Copy link
Owner

@hirokisan hirokisan left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

@hirokisan hirokisan merged commit e0f1786 into hirokisan:main Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants