Skip to content

Consistent logging #14232

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

Merged
merged 31 commits into from
Jul 18, 2025
Merged

Consistent logging #14232

merged 31 commits into from
Jul 18, 2025

Conversation

mkuratczyk
Copy link
Contributor

Make our logging more consistent:

  1. get rid of rabbit_log, rabbit_shovel_log and similar modules
  2. use logger macros directly
  3. remove pid => self() metadata, since that's automatically added by logger
  4. instead of passing the logging domain on every call, set the domain on the process level

The domain should be set on more processes, but we can do that over time. The fact they are missing shouldn't affect anything anyway, since currently we don't log the domain on the logger level, but rather many log strings contain the domain "informally" (eg. peer discovery sets the domain but also prefixes all logs with "Peer discovery:")

@mkuratczyk mkuratczyk force-pushed the consistent-logging branch 6 times, most recently from b77fb53 to 7e3ad60 Compare July 15, 2025 19:01
@mergify mergify bot added the make label Jul 15, 2025
@mkuratczyk mkuratczyk force-pushed the consistent-logging branch 3 times, most recently from e2b7ed3 to 4f3f4b0 Compare July 15, 2025 22:31
@michaelklishin michaelklishin added this to the 4.2.0 milestone Jul 15, 2025
@mkuratczyk mkuratczyk force-pushed the consistent-logging branch 3 times, most recently from 02df90c to 108a39f Compare July 16, 2025 13:56
@mkuratczyk mkuratczyk force-pushed the consistent-logging branch from 8fed766 to f6e718c Compare July 18, 2025 06:44
@ansd ansd self-requested a review July 18, 2025 06:50
Copy link
Member

@ansd ansd left a comment

Choose a reason for hiding this comment

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

There are many places where information such as module, function name, arity, line number are now passed into the format string in addition to the logger macros included by file logger.hrl providing this same information:
https://github.com/erlang/otp/blob/c8ee2093fce4766d52e4f246123818d2273bee92/lib/kernel/include/logger.hrl#L61-L63

Should this PR remove the now duplicated provided infos from the format strings?

EDIT: let's do these changes in a follow up PR

Comment on lines -132 to +133
rabbit_log:info("[~s:~s/~b] " Str,
?LOG_INFO("[~s:~s/~b] " Str,
Copy link
Member

Choose a reason for hiding this comment

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

The INFO macro should be deleted given that the LOG_INFO macro already includes module, function name, and arity.

@@ -332,7 +333,7 @@ consume(Q, Spec, #stream_client{} = QState0)
args := Args,
ok_msg := OkMsg,
acting_user := ActingUser} = Spec,
rabbit_log:debug("~s:~s Local pid resolved ~0p",
?LOG_DEBUG("~s:~s Local pid resolved ~0p",
Copy link
Member

Choose a reason for hiding this comment

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

The LOG_DEBUG already includes module, function name, and arity. There is no need to pass the module and function name again as parameter to the format string.

@@ -3,7 +3,7 @@
-ifdef(TRACE_AMQP).
-warning("AMQP tracing is enabled").
-define(TRACE(Format, Args),
rabbit_log:debug(
?LOG_DEBUG(
Copy link
Member

Choose a reason for hiding this comment

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

Same here

@mkuratczyk mkuratczyk marked this pull request as ready for review July 18, 2025 08:55
@mkuratczyk mkuratczyk merged commit febb580 into main Jul 18, 2025
279 of 284 checks passed
@mkuratczyk mkuratczyk deleted the consistent-logging branch July 18, 2025 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants