Skip to content

Conversation

@johnwason
Copy link
Contributor

This PR contains some preliminary work on an improved logging system inspired by Robot Raconteur. It is designed to carry more information about the log event for displaying to the user in an "event viewer" format, or for clients to automatically interpret the log information to make decisions.

The TesseractLogRecord has this initial format:

struct TesseractLogRecord
    {
        /** The log record error level */
        LogLevel level{LogLevel::Warning};
        /** An identifier for an error. Either a gcc style "diagnostic ID" or a UUID in hex string  */
        std::string error_ident;
        /** The component that generated the message (typically package name or namespace) */
        std::string component;
        /** The subcomponent that generate the message (typically class name) */
        std::string subcomponent;
        /** The instance ID of the object that generated the message (pointer or UUID)*/
        std::string object_instance;
        /** The path of the object. Use string UUIDs of taskflow nodes */
        std::vector<std::string> object_path;
        /** Human readable log message */
        std::string message;
        /** Time of logging event */
        std::chrono::system_clock::time_point time;
        /** The sourcecode filename */
        std::string source_file;
        /** The line within the sourcecode file */
        uint32_t source_line{0};
        /** The source thread */
        std::string thread_id;
        /** Machine readable parameters attached to event */
        std::unordered_map<std::string, std::any> parameters;
    };

This improvement also introduces the concept of LogManager and LogRecordHandler. Ideally all classes in tesseract will carry an instance variable to std::weak_ptr<LogManager>, or possibly a uint32 ID to the log manager currently being used. For the Robot Raconteur service there may be more than one active client so it is necessary to send the log to the correct manager so it is received by the relevant client.

See also https://github.com/robotraconteur/robotraconteur/blob/master/RobotRaconteurCore/include/RobotRaconteur/Logging.h , https://github.com/robotraconteur/robotraconteur/blob/master/RobotRaconteurCore/src/Logging.cpp , and https://github.com/robotraconteur/robotraconteur_standard_robdef/blob/master/group1/com.robotraconteur.eventlog.robdef

This work is still incomplete and is being submitted for discussion.

@codecov
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 0% with 81 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.00%. Comparing base (0bf0f8e) to head (c92291e).

Files with missing lines Patch % Lines
tesseract_common/src/logging.cpp 0.00% 81 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1199      +/-   ##
==========================================
- Coverage   93.40%   93.00%   -0.41%     
==========================================
  Files         272      273       +1     
  Lines       18684    18765      +81     
==========================================
  Hits        17452    17452              
- Misses       1232     1313      +81     
Files with missing lines Coverage Δ
tesseract_common/src/logging.cpp 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@johnwason
Copy link
Contributor Author

It may also make sense to make this a separate library that can be used by other related packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant