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

ApiListener: Log error context only once #10209

Merged
merged 1 commit into from
Oct 31, 2024
Merged

Conversation

yhabteab
Copy link
Member

When logging at the warning level, the logger will automatically look up for registered context and append them to the log entry accordingly.

icinga2/lib/base/logger.cpp

Lines 279 to 287 in 92399a9

if (m_Severity >= LogWarning) {
ContextTrace context;
if (context.GetLength() > 0) {
std::ostringstream trace;
trace << context;
entry.Message += "\nContext:" + trace.str();
}
}

Before

[2024-10-30 17:01:01 +0100] information/ApiListener: Sending replay log for endpoint 'satellite' in zone 'master'.
[2024-10-30 17:01:01 +0100] warning/JsonRpcConnection: API client disconnected for identity 'satellite'
[2024-10-30 17:01:01 +0100] warning/ApiListener: Error while replaying log for endpoint 'satellite': Error: Cannot send message to already disconnected API client 'satellite'!

Context:

        (0) Replaying log for Endpoint 'satellite'
Context:
        (0) Replaying log for Endpoint 'satellite'

[2024-10-30 17:01:01 +0100] warning/ApiListener: Removing API client for endpoint 'satellite'. 0 API clients left.

After

[2024-10-30 16:58:23 +0100] information/ApiListener: Sending replay log for endpoint 'satellite' in zone 'master'.
[2024-10-30 16:58:23 +0100] warning/JsonRpcConnection: API client disconnected for identity 'satellite'
[2024-10-30 16:58:23 +0100] warning/ApiListener: Removing API client for endpoint 'satellite'. 0 API clients left.
[2024-10-30 16:58:23 +0100] warning/ApiListener: Error while replaying log for endpoint 'satellite': Cannot send message to already disconnected API client 'satellite'!
Context:
        (0) Replaying log for Endpoint 'satellite'

[2024-10-30 16:58:23 +0100] information/ApiListener: Finished sending replay log for endpoint 'satellite' in zone 'master'.

When logging at the warning level, the logger will automatically look up
for registered context and append them to the log entry accordingly.
@yhabteab yhabteab added the bug Something isn't working label Oct 30, 2024
@yhabteab yhabteab added this to the 2.15.0 milestone Oct 30, 2024
@cla-bot cla-bot bot added the cla/signed label Oct 30, 2024
@yhabteab yhabteab added the consider backporting Should be considered for inclusion in a bugfix release label Oct 30, 2024
Copy link
Member

@Al2Klimov Al2Klimov left a comment

Choose a reason for hiding this comment

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

Having is better than needing. ;-)

@Al2Klimov Al2Klimov removed the consider backporting Should be considered for inclusion in a bugfix release label Oct 31, 2024
@yhabteab
Copy link
Member Author

Why did you remove the backport label? This duplication originates from commit 932a534, which is backported to the 2.14 support branch.

@Al2Klimov Al2Klimov added the consider backporting Should be considered for inclusion in a bugfix release label Oct 31, 2024
@yhabteab yhabteab merged commit d894792 into master Oct 31, 2024
27 checks passed
@yhabteab yhabteab deleted the log-error-context-only-once branch October 31, 2024 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cla/signed consider backporting Should be considered for inclusion in a bugfix release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants