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

Add debug mode with slog for logging #149

Merged
merged 1 commit into from
Apr 20, 2024
Merged

Add debug mode with slog for logging #149

merged 1 commit into from
Apr 20, 2024

Conversation

catatsuy
Copy link
Owner

This pull request introduces changes to the internal/cli/cli.go, internal/slack/client.go, and internal/slack/client_test.go files. The major changes include the addition of a debug mode in the CLI, switching from the standard log package to the structured log package (slog), and updating the tests to reflect these changes.

Changes to the CLI (internal/cli/cli.go):

  • Imported the log/slog package for structured logging.
  • Added a debugMode boolean variable to the Run function. [1] [2]
  • Created a new slog.Logger instance based on the debugMode variable.
  • Updated the NewClientForPostFile and NewClient functions to pass the logger instance.

Changes to the Slack client (internal/slack/client.go):

  • Replaced the standard log package with the log/slog package.
  • Replaced the Logger field in the Client struct with a slog.Logger instance.
  • Updated the NewClient and NewClientForPostFile functions to accept a slog.Logger instance. [1] [2]
  • Removed the creation of a discard logger in the NewClient and NewClientForPostFile functions.
  • Added debug logs to the PostText and PostFile functions. [1] [2]

Changes to the Slack client tests (internal/slack/client_test.go):

  • Imported the log/slog package.
  • Updated all test functions to create a new slog.Logger instance and pass it to the NewClient and NewClientForPostFile functions. [1] [2] [3] [4] [5] [6] [7] [8] [9]

@catatsuy catatsuy merged commit 405abea into master Apr 20, 2024
5 checks passed
@catatsuy catatsuy deleted the feature_use_slog branch April 20, 2024 08:48
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.

1 participant