Skip to content

Conversation

@esohns
Copy link
Contributor

@esohns esohns commented Nov 22, 2025

…o print time periods.

These logging calls invoke ACE::timestamp, which in turn (erroneously) invokes localtime_r (instead of gmtime_r). Localtime(_r) always adds the timezone offset (if any) to the hour field, which results in a wrong result string (when you live anywhere outside of the GMT time zone)

Summary by CodeRabbit

  • New Features

    • Added duration formatting and a new log format specifier (%Y) to print durations in logs.
  • Documentation

    • Clarified timestamp text to "hour:minute:second.microsecond" and documented %Y usage and overflow behavior for long durations.
  • Behavior

    • Log formatting now supports the %Y specifier to render durations and updates output handling accordingly.

✏️ Tip: You can customize this high-level summary in your review settings.

…o print time periods.

These logging calls invoke ACE::timestamp, which in turn (erroneously) invokes localtime_r (instead of gmtime_r). Localtime(_r) always adds the timezone offset (if any) to the hour field, which results in a wrong result string (when you live anywhere outside of the GMT time zone)
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 22, 2025

Walkthrough

Added ACE::duration to format ACE_Time_Value durations as "hour:minute:second.microsecond." and declared it public; integrated a new log-format specifier %Y (requires #) that invokes ACE::duration; updated %T timestamp help text and clarified zero time_value behavior.

Changes

Cohort / File(s) Summary
Duration implementation & header
ACE/ace/ACE.cpp, ACE/ace/ACE.h
Added ACE::duration(const ACE_Time_Value&, ACE_TCHAR[], size_t) implementation and public declaration; updated timestamp comment to clarify that passing ACE_Time_Value::zero uses current time retrieval.
Log formatting: new %Y specifier & help text
ACE/ace/Log_Msg.cpp, ACE/ace/Log_Msg.h
Added handling for %Y in formatting and conversion processing: when %Y is used with # modifier, Log_Msg invokes ACE::duration to render a duration; added %Y help text and adjusted %T help text to reflect "hour:minute:sec.usec" formatting.

Sequence Diagram(s)

sequenceDiagram
    participant Formatter as Log_Msg formatter
    participant ACE as ACE utility
    participant Out as Output buffer

    Formatter->>Formatter: parse format string
    alt "%Y" with '#' modifier
        Formatter->>ACE: ACE::duration(duration_value, buf, len)
        ACE-->>Formatter: formatted duration string
        Formatter->>Out: append formatted duration (update lengths)
    else "%Y" without '#'
        Formatter->>Formatter: emit error / fallback handling
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Areas needing extra attention:
    • Field widths and microsecond formatting correctness in ACE::duration.
    • Buffer-length validation and overflow handling in ACE::duration and Log_Msg.cpp.
    • Modifier parsing and error/fallback behavior for %Y in Log_Msg.cpp.

Suggested reviewers

  • mitza-oci

Poem

🐇 I hopped through code to mark each span,

I stitched the ticks with a careful plan,
Now logs display each hour, minute, beat,
Small seconds dancing tidy and neat,
A nibble of time — precise and sweet.

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions fixing a bug with '%#T' format strings, but the PR primarily adds a new '%Y' format specifier for duration logging and updates documentation. The actual bug fix (localtime_r to gmtime_r change) is not clearly visible in the changes summary. Update the title to accurately reflect the main changes: adding a new duration formatting feature (%Y specifier) or clarify that it's specifically about the gmtime_r fix for timestamp formatting.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3bbf8f3 and 1fdf1ba.

📒 Files selected for processing (1)
  • ACE/ace/Log_Msg.cpp (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • ACE/ace/Log_Msg.cpp
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: windows-2022 vs2022
  • GitHub Check: ubuntu-22.04 g++-12
  • GitHub Check: VS2022Release64
  • GitHub Check: VS2022WChar
  • GitHub Check: VS2022Debug32
  • GitHub Check: VS2022Debug64Cxx17
  • GitHub Check: VS2022WChar
  • GitHub Check: VS2022Debug64Cxx20
  • GitHub Check: macos-13-C++
  • GitHub Check: MINGW64-gcc
  • GitHub Check: macos-14-C++
  • GitHub Check: ubuntu-24.04 g++-10 CodeQL
  • GitHub Check: ubuntu-24.04 clang++-20 c++23
  • GitHub Check: ubuntu-22.04 clang++-13
  • GitHub Check: ubuntu-24.04 g++-13
  • GitHub Check: ubuntu-22.04 clang++-12
  • GitHub Check: ubuntu-22.04 g++-9
  • GitHub Check: ubuntu-22.04 g++-10
  • GitHub Check: alpine-3.18
  • GitHub Check: ubuntu-24.04 g++

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between edd2dd0 and 612663c.

📒 Files selected for processing (1)
  • ACE/ace/ACE.cpp (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: iguessthislldo
Repo: DOCGroup/ACE_TAO PR: 2462
File: ACE/ace/Time_Value.h:0-0
Timestamp: 2025-09-03T01:30:16.319Z
Learning: In ACE_Time_Value, the set(time_t, suseconds_t) method automatically calls normalize() which handles negative microsecond values by adjusting seconds and microseconds into canonical form, so explicit normalization in template methods that call set() is unnecessary.
Learnt from: iguessthislldo
Repo: DOCGroup/ACE_TAO PR: 2462
File: ACE/ace/Time_Value.h:0-0
Timestamp: 2025-09-03T01:30:16.319Z
Learning: The ACE_Time_Value::set(time_t, suseconds_t) method normalizes negative microsecond values, so explicit normalization in template methods that call set is redundant.
📚 Learning: 2025-09-03T01:30:16.319Z
Learnt from: iguessthislldo
Repo: DOCGroup/ACE_TAO PR: 2462
File: ACE/ace/Time_Value.h:0-0
Timestamp: 2025-09-03T01:30:16.319Z
Learning: The ACE_Time_Value::set(time_t, suseconds_t) method normalizes negative microsecond values, so explicit normalization in template methods that call set is redundant.

Applied to files:

  • ACE/ace/ACE.cpp
📚 Learning: 2025-09-03T01:30:16.319Z
Learnt from: iguessthislldo
Repo: DOCGroup/ACE_TAO PR: 2462
File: ACE/ace/Time_Value.h:0-0
Timestamp: 2025-09-03T01:30:16.319Z
Learning: In ACE_Time_Value, the set(time_t, suseconds_t) method automatically calls normalize() which handles negative microsecond values by adjusting seconds and microseconds into canonical form, so explicit normalization in template methods that call set() is unnecessary.

Applied to files:

  • ACE/ace/ACE.cpp
🧬 Code graph analysis (1)
ACE/ace/ACE.cpp (1)
ACE/ace/OS_NS_time.cpp (1)
  • localtime_r (17-17)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: macos-13-C++
  • GitHub Check: ubuntu-24.04 g++-10 CORBA/e compact
  • GitHub Check: ubuntu-24.04 g++-12
  • GitHub Check: ubuntu-24.04 g++-13
  • GitHub Check: ubuntu-24.04 clang++-20
  • GitHub Check: ubuntu-22.04 clang++-12
  • GitHub Check: ubuntu-24.04 clang++-20 c++23
  • GitHub Check: ubuntu-24.04 g++-10 CORBA/e micro
  • GitHub Check: ubuntu-24.04 g++-10 CodeQL
  • GitHub Check: ubuntu-24.04 g++-14
  • GitHub Check: ubuntu-24.04 g++-10 ACE for TAO
  • GitHub Check: ubuntu-24.04 g++-10 wchar
  • GitHub Check: ubuntu-24.04 clang++-16
  • GitHub Check: ubuntu-22.04 clang++-13
  • GitHub Check: ubuntu-24.04 clang++-14
  • GitHub Check: ubuntu-24.04 g++-11
  • GitHub Check: ubuntu-22.04 g++-9
  • GitHub Check: MINGW64-gcc
  • GitHub Check: ubuntu-22.04 g++-10
  • GitHub Check: alpine-3.18

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
ACE/ace/ACE.h (1)

480-518: timestamp/duration API docs align with implementation; consider clarifying 24h limitation wording

  • The timestamp comment now explicitly calls out the ACE_Time_Value::zerogettimeofday() behavior, which matches the implementation in ACE::timestamp and is helpful for callers.
  • The new duration(const ACE_Time_Value&, ACE_TCHAR*, size_t) API is documented with a minimum buffer size and note about durations ≥ 24 hours; this matches the formatting width and the fact that only tm_hour/min/sec are printed.

If you want to be more explicit, you could slightly rephrase “cannot handle durations larger or equal to 24 hours” to mention that the hours field effectively wraps at 24h (as also hinted by the %Y docs), but it’s not required for correctness.

ACE/ace/Log_Msg.h (1)

545-562: Logging format docs for %T/%Y are consistent; you may want to tighten the %Y contract

  • Updating %T to hour:minute:sec.usec with # expecting ACE_Time_Value* matches the actual ACE::timestamp behavior.
  • The new %Y description correctly documents the duration use case and the ≥24h overflow caveat, in line with ACE::duration.

Given that durations really only make sense with an explicit ACE_Time_Value*, you might consider saying that plain %Y is “unsupported/invalid” rather than “currently unspecified”, to make the intended usage (%#Y) unambiguous.

ACE/ace/ACE.cpp (1)

2433-2464: ACE::duration implementation correctly fixes the timezone bug for durations

  • The new ACE::duration uses gmtime_r on the duration seconds and prints HH:MM:SS.uuuuuu, which avoids applying any local timezone offset—this directly addresses the original %#T/time-period bug.
  • The duration_len < 16 guard matches the required fixed-width output and returns EINVAL consistently with other ACE time-format helpers.
  • The behavior for very long or negative durations is limited (wrap modulo 24h / odd values), but this is already called out in the surrounding documentation and %Y description, so it’s an acceptable constraint for this API.

If you later need to support durations ≥24h or signed durations more explicitly, you could extend this helper (e.g., by returning an error for out-of-range values or formatting days separately), but that’s not necessary for this bugfix.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 612663c and 78bcf26.

📒 Files selected for processing (4)
  • ACE/ace/ACE.cpp (2 hunks)
  • ACE/ace/ACE.h (2 hunks)
  • ACE/ace/Log_Msg.cpp (2 hunks)
  • ACE/ace/Log_Msg.h (2 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: likema
Repo: DOCGroup/ACE_TAO PR: 2332
File: ACE/ace/Ping_Socket.cpp:227-232
Timestamp: 2025-02-13T18:50:43.028Z
Learning: In ACE framework's logging system (ACE_Log_Msg::log), `%b` is the correct format specifier for printing ssize_t values, not the standard C++ `%zd`.
Learnt from: likema
Repo: DOCGroup/ACE_TAO PR: 2332
File: ACE/ace/Ping_Socket.cpp:270-277
Timestamp: 2025-02-13T18:51:40.093Z
Learning: In ACE_Log_Msg logging system, '%b' is the correct format specifier for ssize_t values, not '%zd'. This is a custom format specifier specific to ACE's logging system.
📚 Learning: 2025-02-13T18:51:40.093Z
Learnt from: likema
Repo: DOCGroup/ACE_TAO PR: 2332
File: ACE/ace/Ping_Socket.cpp:270-277
Timestamp: 2025-02-13T18:51:40.093Z
Learning: In ACE_Log_Msg logging system, '%b' is the correct format specifier for ssize_t values, not '%zd'. This is a custom format specifier specific to ACE's logging system.

Applied to files:

  • ACE/ace/Log_Msg.cpp
  • ACE/ace/ACE.cpp
📚 Learning: 2025-02-13T18:50:43.028Z
Learnt from: likema
Repo: DOCGroup/ACE_TAO PR: 2332
File: ACE/ace/Ping_Socket.cpp:227-232
Timestamp: 2025-02-13T18:50:43.028Z
Learning: In ACE framework's logging system (ACE_Log_Msg::log), `%b` is the correct format specifier for printing ssize_t values, not the standard C++ `%zd`.

Applied to files:

  • ACE/ace/Log_Msg.cpp
  • ACE/ace/ACE.cpp
📚 Learning: 2025-09-03T01:30:16.319Z
Learnt from: iguessthislldo
Repo: DOCGroup/ACE_TAO PR: 2462
File: ACE/ace/Time_Value.h:0-0
Timestamp: 2025-09-03T01:30:16.319Z
Learning: In ACE_Time_Value, the set(time_t, suseconds_t) method automatically calls normalize() which handles negative microsecond values by adjusting seconds and microseconds into canonical form, so explicit normalization in template methods that call set() is unnecessary.

Applied to files:

  • ACE/ace/ACE.cpp
📚 Learning: 2025-09-03T01:30:16.319Z
Learnt from: iguessthislldo
Repo: DOCGroup/ACE_TAO PR: 2462
File: ACE/ace/Time_Value.h:0-0
Timestamp: 2025-09-03T01:30:16.319Z
Learning: The ACE_Time_Value::set(time_t, suseconds_t) method normalizes negative microsecond values, so explicit normalization in template methods that call set is redundant.

Applied to files:

  • ACE/ace/ACE.cpp
📚 Learning: 2025-02-13T18:51:40.093Z
Learnt from: likema
Repo: DOCGroup/ACE_TAO PR: 2332
File: ACE/ace/Ping_Socket.cpp:270-277
Timestamp: 2025-02-13T18:51:40.093Z
Learning: In ACE_Log_Msg logging system, '%b' is the correct format specifier to print ssize_t values, not '%zd'.

Applied to files:

  • ACE/ace/ACE.cpp
🧬 Code graph analysis (2)
ACE/ace/ACE.h (1)
ACE/ace/ACE.cpp (2)
  • duration (2437-2464)
  • duration (2438-2440)
ACE/ace/Log_Msg.cpp (2)
ACE/ace/ACE.cpp (2)
  • duration (2437-2464)
  • duration (2438-2440)
ACE/ace/Time_Value.h (1)
  • ACE_Time_Value (48-128)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (21)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: VS2022Debug64
  • GitHub Check: VS2022Debug32
  • GitHub Check: VS2022Release64
  • GitHub Check: VS2022Debug64Cxx17
  • GitHub Check: VS2022WChar
  • GitHub Check: VS2022WChar
  • GitHub Check: VS2022Debug64Cxx20
  • GitHub Check: VS2022Release32
  • GitHub Check: MINGW64-gcc
  • GitHub Check: macos-14-C++
  • GitHub Check: macos-13-C++
  • GitHub Check: ubuntu-24.04 g++-13
  • GitHub Check: ubuntu-24.04 g++-10 CORBA/e micro
  • GitHub Check: ubuntu-24.04 g++-10 ACE for TAO
  • GitHub Check: ubuntu-24.04 clang++-14
  • GitHub Check: ubuntu-24.04 g++-14
  • GitHub Check: ubuntu-24.04 g++-10 CORBA/e compact
  • GitHub Check: ubuntu-24.04 clang++-16
  • GitHub Check: windows-2022 vs2022
  • GitHub Check: ubuntu-24.04 g++
🔇 Additional comments (1)
ACE/ace/ACE.cpp (1)

2391-2431: timestamp comment now accurately reflects behavior; no functional change

The only change here is the comment text (colon → dot before microseconds); the implementation still uses localtime_r and the ACE_Time_Value::zerogettimeofday() path, so existing %T behavior remains intact and the docs are now aligned with the actual format string.

@esohns
Copy link
Contributor Author

esohns commented Nov 22, 2025

AFAICT the CodeFactor issue is already addressed in the code and can be safely ignored

@jwillemsen jwillemsen added the needs review Needs to be reviewed label Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review Needs to be reviewed

Development

Successfully merging this pull request may close these issues.

2 participants