Skip to content

Expand --count option #424

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 4 commits into from
Jun 4, 2025
Merged

Expand --count option #424

merged 4 commits into from
Jun 4, 2025

Conversation

tgreenx
Copy link
Contributor

@tgreenx tgreenx commented Feb 25, 2025

Purpose

This PR proposes an update to the --count option.

Context

N/A

Changes

  • Add a count of each message tag for each severity level
  • Dynamically format the table as to support translated strings (e.g. headers and levels)

How to test this PR

Run any test with the --count option. Check that the formatting is done correctly.
Output:

$ zonemaster-cli --count --raw --no-ipv6 --test basic02 afnic.fr


 Level  Number of log entries
======  =====================
  INFO                      2
 DEBUG                     53
DEBUG2                    178
DEBUG3                     65

 Level            Message tag   Count
======  =====================   =====
  INFO  B02_AUTH_RESPONSE_SOA       1
  INFO         GLOBAL_VERSION       1
 DEBUG     DEPENDENCY_VERSION       9
 DEBUG         EXTERNAL_QUERY      30
 DEBUG           IPV4_ENABLED       4
 DEBUG          IPV6_DISABLED       4
 DEBUG             MODULE_END       1
 DEBUG         MODULE_VERSION       1
 DEBUG             START_TIME       1
 DEBUG          TEST_CASE_END       1
 DEBUG        TEST_CASE_START       1
 DEBUG            TEST_TARGET       1
DEBUG2          CACHE_CREATED       7
DEBUG2           IPV6_BLOCKED      28
DEBUG2            IS_REDIRECT      14
DEBUG2             NS_CREATED      38
DEBUG2                  QUERY      35
DEBUG2          RECURSE_QUERY      56
DEBUG3          CACHED_RETURN      35
DEBUG3      EXTERNAL_RESPONSE      30

Also run it with the --json option, and check that the output is correct:

$ zonemaster-cli --count --json --raw --no-ipv6 --test basic02 afnic.fr | jq
{
  "count": {
    "by_level": {
      "DEBUG": 53,
      "DEBUG2": 178,
      "DEBUG3": 65,
      "INFO": 2
    },
    "by_message_tag": {
      "DEBUG": {
        "DEPENDENCY_VERSION": 9,
        "EXTERNAL_QUERY": 30,
        "IPV4_ENABLED": 4,
        "IPV6_DISABLED": 4,
        "MODULE_END": 1,
        "MODULE_VERSION": 1,
        "START_TIME": 1,
        "TEST_CASE_END": 1,
        "TEST_CASE_START": 1,
        "TEST_TARGET": 1
      },
      "DEBUG2": {
        "CACHE_CREATED": 7,
        "IPV6_BLOCKED": 28,
        "IS_REDIRECT": 14,
        "NS_CREATED": 38,
        "QUERY": 35,
        "RECURSE_QUERY": 56
      },
      "DEBUG3": {
        "CACHED_RETURN": 35,
        "EXTERNAL_RESPONSE": 30
      },
      "INFO": {
        "B02_AUTH_RESPONSE_SOA": 1,
        "GLOBAL_VERSION": 1
      }
    }
  },
  "results": []
}

@tgreenx tgreenx added the V-Minor Versioning: The change gives an update of minor in version. label Feb 25, 2025
@tgreenx tgreenx added this to the v2025.1 milestone Feb 25, 2025
@tgreenx
Copy link
Contributor Author

tgreenx commented May 20, 2025

@mattias-p @matsduf @marc-vanderwal please review.

Copy link
Member

@mattias-p mattias-p left a comment

Choose a reason for hiding this comment

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

Neat feature. Maybe add a unit test to make sure it continues to work in future releases?

@matsduf matsduf dismissed their stale review June 2, 2025 13:53

It is OK as is.

tgreenx added 4 commits June 2, 2025 16:00
- Add a count of each message tag for each severity level
- Fixes translation of strings
- Dynamically format the tables as to support translated strings
- Refactoring
@tgreenx
Copy link
Contributor Author

tgreenx commented Jun 3, 2025

@matsduf @mattias-p Rebased on latest develop, and addressed review comments (see 5ee387e). Please re-review.

@tgreenx tgreenx requested review from mattias-p and matsduf June 3, 2025 12:19
@tgreenx tgreenx merged commit 6fc9f5f into zonemaster:develop Jun 4, 2025
3 checks passed
@tgreenx tgreenx deleted the update-count branch June 4, 2025 17:00
@marc-vanderwal
Copy link
Contributor

Release testing done on Rocky Linux 9.

When the system locale is set to French, there is a small inconsistency in how the table is formatted. The first table has DEBUG translated as DEBOGUE, but not the second one.

This is the output I get on my system:

$ zonemaster-cli --count --raw --no-ipv6 --test basic02 afnic.fr


 Niveau Number of log entries
======= =====================
   INFO                     2
DEBOGUE                    53
 DEBUG2                   178
 DEBUG3                    65

 Niveau           Message tag   Count
======= =====================   =====
   INFO B02_AUTH_RESPONSE_SOA       1
   INFO        GLOBAL_VERSION       1
  DEBUG    DEPENDENCY_VERSION       9
  DEBUG        EXTERNAL_QUERY      30
  DEBUG          IPV4_ENABLED       4
  DEBUG         IPV6_DISABLED       4
  DEBUG            MODULE_END       1
  DEBUG        MODULE_VERSION       1
  DEBUG            START_TIME       1
  DEBUG         TEST_CASE_END       1
  DEBUG       TEST_CASE_START       1
  DEBUG           TEST_TARGET       1
 DEBUG2         CACHE_CREATED       7
 DEBUG2          IPV6_BLOCKED      28
 DEBUG2           IS_REDIRECT      14
 DEBUG2            NS_CREATED      38
 DEBUG2                 QUERY      35
 DEBUG2         RECURSE_QUERY      56
 DEBUG3         CACHED_RETURN      35
 DEBUG3     EXTERNAL_RESPONSE      30

@marc-vanderwal marc-vanderwal added the S-ReleaseTested Status: The PR has been successfully tested in release testing label Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-ReleaseTested Status: The PR has been successfully tested in release testing V-Minor Versioning: The change gives an update of minor in version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants