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

refactor: Remove extra log levels #634

Merged
merged 2 commits into from
Jul 14, 2022

Conversation

fredcarle
Copy link
Collaborator

Relevant issue(s)

Resolves #612

Description

This PR removes Warn, FeedbackWarn and FeedbackDebug. It was initially going to remove Fatal and FatalE as well but other out of scope changes need to be done prior to considering this.

Keeping just this minor reduction for now and will revisit for v0.3.1.

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

Unit testing

Specify the platform(s) on which this was tested:

  • MacOS

@fredcarle fredcarle added refactor This issue specific to or requires *notable* refactoring of existing codebases and components area/logging Related to the logging/logger system action/no-benchmark Skips the action that runs the benchmark. labels Jul 14, 2022
@fredcarle fredcarle added this to the DefraDB v0.3 milestone Jul 14, 2022
@fredcarle fredcarle requested a review from a team July 14, 2022 00:01
@fredcarle fredcarle self-assigned this Jul 14, 2022
@codecov
Copy link

codecov bot commented Jul 14, 2022

Codecov Report

Merging #634 (eab50ad) into develop (303b43a) will decrease coverage by 0.04%.
The diff coverage is 0.00%.

❗ Current head eab50ad differs from pull request most recent head 0ccf822. Consider uploading reports for the commit 0ccf822 to get more accurate results

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #634      +/-   ##
===========================================
- Coverage    57.00%   56.96%   -0.05%     
===========================================
  Files          122      122              
  Lines        14661    14646      -15     
===========================================
- Hits          8358     8343      -15     
  Misses        5588     5588              
  Partials       715      715              
Impacted Files Coverage Δ
logging/logger.go 76.35% <ø> (-2.18%) ⬇️
logging/logging.go 100.00% <ø> (ø)
net/peer.go 12.54% <0.00%> (ø)

@orpheuslummis
Copy link
Contributor

orpheuslummis commented Jul 14, 2022

It'd be be nice to communicate to zap the exact levels we're using, instead of it internally using its default 7, but I could only find a way to add more levels

@@ -462,7 +462,7 @@ func stopGRPCServer(ctx context.Context, server *grpc.Server) {
select {
case <-timer.C:
server.Stop()
log.Warn(ctx, "Peer gRPC server was shutdown ungracefully")
log.Info(ctx, "Peer gRPC server was shutdown ungracefully")
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like an Error

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To me this is not an error. An error is something that needs to be handled by the caller. This is just a message sent back to the console/logs to let the user know that something happened. Hence it's just Information.

Copy link
Contributor

@orpheuslummis orpheuslummis Jul 14, 2022

Choose a reason for hiding this comment

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

Do we want to prepend something like "Warning" on some of the Info messages? I'm towards yes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to prepend something like "Warning" on some of the Info messages? I'm towards yes.

🤣 Please dont do this lol. If someone really wants it to be a warning then they should use/re-introduce it as a log level (I dont think they should lol, but it is better than doing this)

@orpheuslummis
Copy link
Contributor

orpheuslummis commented Jul 14, 2022

A) needs to remove in config as well:

case "warn":


B) why remove FeedbackDebug ?


C) other instances ...

"log level to use. Options are debug, info, warn, error, fatal",

assert.Equal(t, "warn", cfg.Logging.Level)

# Log level. Options are debug, info, warn, error, fatal


D) should this be modified as well?

const (

along with

return []LogLevelTestCase{

@fredcarle
Copy link
Collaborator Author

A, C and D yes. Didn't think about those.

B, FeedbackDebug makes no sense to me. Debug is a message for Defra devs. Hence the logs will not be sent to file if we are doing development. And even if they are, we're looking at them. Feedback is for users. Not Devra devs.

@fredcarle
Copy link
Collaborator Author

It'd be be nice to communicate to zap the exact levels we're using, instead of it internally using its default 7, but I could only find a way to add more levels

Does it matter though? We are pretty much doing that by only exposing the log levels we want.

@orpheuslummis
Copy link
Contributor

It'd be be nice to communicate to zap the exact levels we're using, instead of it internally using its default 7, but I could only find a way to add more levels

Does it matter though? We are pretty much doing that by only exposing the log levels we want.

With that zap would do slightly less internal work, but it doesn't matter too much, and it a quick look into it led me to guess that lowering levels is not possible with zap anyway.

Copy link
Contributor

@AndrewSisley AndrewSisley left a comment

Choose a reason for hiding this comment

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

LGTM - cheers Fred

Copy link
Contributor

@orpheuslummis orpheuslummis left a comment

Choose a reason for hiding this comment

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

Approved conditional on A, C and D discussed above being fixed.

@fredcarle fredcarle merged commit 637fc44 into develop Jul 14, 2022
@fredcarle fredcarle deleted the fredcarle/refactor/I612-reduce-logging-levels branch July 14, 2022 17:27
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
Relevant issue(s)
Resolves sourcenetwork#612

Description
This PR removes Warn, FeedbackWarn and FeedbackDebug. It was initially going to remove Fatal and FatalE as well but other out of scope changes need to be done prior to considering this.

Keeping just this minor reduction for now and will revisit for v0.3.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/logging Related to the logging/logger system refactor This issue specific to or requires *notable* refactoring of existing codebases and components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

logging level reduction
3 participants