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

Finish switching to use slog for logging #660

Merged
merged 3 commits into from
Oct 25, 2023
Merged

Finish switching to use slog for logging #660

merged 3 commits into from
Oct 25, 2023

Conversation

norkans7
Copy link
Contributor

@norkans7 norkans7 commented Oct 12, 2023

Removes logrus use and add sentry handler for slog

@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

Merging #660 (b65220a) into main (6368e43) will increase coverage by 0.27%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main     #660      +/-   ##
==========================================
+ Coverage   74.04%   74.31%   +0.27%     
==========================================
  Files         100       99       -1     
  Lines       13177    13129      -48     
==========================================
  Hits         9757     9757              
+ Misses       2732     2684      -48     
  Partials      688      688              

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@norkans7 norkans7 force-pushed the slog-last branch 2 times, most recently from 08c0de8 to 1735228 Compare October 12, 2023 16:06
defer sentry.Flush(2 * time.Second)

logger = slog.New(
slogmulti.Fanout(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to use multi handlers here so that we can log the error both to sentry and the text logs on the servers

@norkans7 norkans7 changed the title Slog last Finish switching to use slog for logging Oct 13, 2023
@norkans7 norkans7 marked this pull request as ready for review October 13, 2023 10:25
@norkans7 norkans7 requested a review from rowanseymour October 13, 2023 10:30
@@ -87,51 +89,61 @@ func main() {
}

// configure our logger
logrus.SetOutput(os.Stdout)
level, err := logrus.ParseLevel(config.LogLevel)
loggerLevel := new(slog.LevelVar)
Copy link
Member

Choose a reason for hiding this comment

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

do we need this? or can we just parse the Level value and then create the handler?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

using the levelVar is the only approach to support later changing the log level, but we change to use the parsed level and create a new handler.

@norkans7 norkans7 requested a review from rowanseymour October 13, 2023 13:59
Copy link
Member

@rowanseymour rowanseymour left a comment

Choose a reason for hiding this comment

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

Woohoo!

@rowanseymour rowanseymour merged commit 6fd730b into main Oct 25, 2023
@rowanseymour rowanseymour deleted the slog-last branch October 25, 2023 21:01
@github-actions github-actions bot locked and limited conversation to collaborators Oct 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants