Icinga / Icinga/icinga2

Logger severity string parsed for each log message

Open
#9,534 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/log core/quality good first issue
Dominant language
C++
Stars
2.2k
Forks
616
Avg merge
5d 6h
Merged PRs (30d)
10

Description

For each log message and logger, Log::~Log() calls Logger::GetMinSeverity():
https://github.com/Icinga/icinga2/blob/d20f3d7c84c23f190f4f4638d4c1be0f07fdf41e/lib/base/logger.cpp#L241

Which in turn calls Logger::StringToSeverity() each time:
https://github.com/Icinga/icinga2/blob/d20f3d7c84c23f190f4f4638d4c1be0f07fdf41e/lib/base/logger.cpp#L88

Which in turn compares the string against all severities each time:
https://github.com/Icinga/icinga2/blob/d20f3d7c84c23f190f4f4638d4c1be0f07fdf41e/lib/base/logger.cpp#L123-L137

Instead, the severity string should be parsed once and then this value should be used.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/base/logger.cpp, following the Log::~Log(), Logger::GetMinSeverity(), and Logger::StringToSeverity() call chain linked in the issue. Confirm where the severity string is repeatedly parsed, then make the parsed value reusable while preserving existing severity behavior. Done means each log message no longer performs the repeated string comparisons.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
observability-sre, performance
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.