Skip to content

Conversation

@mh0lt
Copy link
Contributor

@mh0lt mh0lt commented Jun 9, 2023

This is another update to logging to replace the root logger with a contextual logger

@AlexeyAkhunov AlexeyAkhunov marked this pull request as ready for review June 9, 2023 13:13
httpEndpoint := fmt.Sprintf("%s:%d", cfg.HttpListenAddress, cfg.HttpPort)

logger.Trace("TraceRequests = %t\n", cfg.TraceRequests)
logger.Trace(fmt.Sprintf("TraceRequests = %t", cfg.TraceRequests))
Copy link
Collaborator

Choose a reason for hiding this comment

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

@mh0lt hi.

  • add prefix like [rpc] - because erigon has many components
  • logs formatting is expensive and this is reason why usually "lazy". For example: if log-level is "Info" then no reason to format all Trace messages. Our logger support "lazy" formatting - just change it to logger.Trace("[rpc] config", "TraceRequests", cfg.TraceRequests")
  • rpcdaemon doesn't print much of logs at startup (same as Erigon) - so, probably no much reasons to hide this log line (i mean - maybe can increase to Info) level. And maybe even print many other cfg fields in this log line.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would just use logger.Trace("TraceRequests", "on", cfg.TraceRequests) or remove these lines altogether

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, happy to remove the lines.

I have a couple of questions though:

Isn't something like [rpc] supported by the logger context ? Then you don't need to add it for every log message.

Also is there a way of checking the current log level in order to just avoid the execution cost of preparing the log output in the first place, even if the logger is not formatting it will still incur the execution time of any parameter preparation ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I think we need to start using logger context instead of prefixes.

Not sure about the way of checking the level, I think it is not possible because it is ultimately decided by the log handles that filter out the log messages before they are directed to a specific place (console, file, etc.)

@AlexeyAkhunov AlexeyAkhunov merged commit 1e575ea into devel Jun 10, 2023
@AlexeyAkhunov AlexeyAkhunov deleted the devnet_bor branch June 10, 2023 06:39
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.

4 participants