Rerun C++ SDK
Loading...
Searching...
No Matches
rerun::archetypes::TextLog Struct Reference

Archetype: A log entry in a text log, comprised of a text body and its log level. More...

#include <rerun/archetypes/text_log.hpp>

Public Types

using IndicatorComponent = components::IndicatorComponent< IndicatorComponentName >
 Indicator component, used to identify the archetype when converting to a list of components.
 

Public Member Functions

 TextLog (TextLog &&other)=default
 
 TextLog (rerun::components::Text _text)
 
TextLog with_level (rerun::components::TextLogLevel _level) &&
 The verbosity level of the message.
 
TextLog with_color (rerun::components::Color _color) &&
 Optional color to use for the log line in the Rerun Viewer.
 
size_t num_instances () const
 Returns the number of primary instances of this archetype.
 

Public Attributes

rerun::components::Text text
 The body of the message.
 
std::optional< rerun::components::TextLogLevellevel
 The verbosity level of the message.
 
std::optional< rerun::components::Colorcolor
 Optional color to use for the log line in the Rerun Viewer.
 

Static Public Attributes

static constexpr const char IndicatorComponentName [] = "rerun.components.TextLogIndicator"
 

Detailed Description

Archetype: A log entry in a text log, comprised of a text body and its log level.

Example

text_log_integration:

image

#include <loguru.hpp>
#include <rerun.hpp>
void loguru_to_rerun(void* user_data, const loguru::Message& message) {
// NOTE: `rerun::RecordingStream` is thread-safe.
const rerun::RecordingStream* rec = reinterpret_cast<const rerun::RecordingStream*>(user_data);
if (message.verbosity == loguru::Verbosity_FATAL) {
} else if (message.verbosity == loguru::Verbosity_ERROR) {
} else if (message.verbosity == loguru::Verbosity_WARNING) {
} else if (message.verbosity == loguru::Verbosity_INFO) {
} else if (message.verbosity == loguru::Verbosity_1) {
} else if (message.verbosity == loguru::Verbosity_2) {
} else {
level = rerun::TextLogLevel(std::to_string(message.verbosity));
}
rec->log(
"logs/handler/text_log_integration",
rerun::TextLog(message.message).with_level(level)
);
}
int main() {
const auto rec = rerun::RecordingStream("rerun_example_text_log_integration");
// Log a text entry directly:
rec.log(
"logs",
rerun::TextLog("this entry has loglevel TRACE").with_level(rerun::TextLogLevel::Trace)
);
loguru::add_callback(
"rerun",
loguru_to_rerun,
const_cast<void*>(reinterpret_cast<const void*>(&rec)),
loguru::Verbosity_INFO
);
LOG_F(INFO, "This INFO log got added through the standard logging interface");
loguru::remove_callback("rerun"); // we need to do this before `rec` goes out of scope
}
void exit_on_failure() const
Calls the handle method and then exits the application with code 1 if the error is not Ok.
A RecordingStream handles everything related to logging data into Rerun.
Definition recording_stream.hpp:57
Error spawn(const SpawnOptions &options={}, float flush_timeout_sec=2.0) const
Spawns a new Rerun Viewer process from an executable available in PATH, then connects to it over TCP.
void log(std::string_view entity_path, const Ts &... archetypes_or_collectiones) const
Logs one or more archetype and/or component batches.
Definition recording_stream.hpp:320
Archetype: A log entry in a text log, comprised of a text body and its log level.
Definition text_log.hpp:81
std::optional< rerun::components::TextLogLevel > level
The verbosity level of the message.
Definition text_log.hpp:88
TextLog with_level(rerun::components::TextLogLevel _level) &&
The verbosity level of the message.
Definition text_log.hpp:108
Component: The severity level of a text log message.
Definition text_log_level.hpp:30
static const TextLogLevel Info
Designates useful information.
Definition text_log_level.hpp:46
static const TextLogLevel Debug
Designates lower priority information.
Definition text_log_level.hpp:49
static const TextLogLevel Warning
Designates hazardous situations.
Definition text_log_level.hpp:43
static const TextLogLevel Trace
Designates very low priority, often extremely verbose, information.
Definition text_log_level.hpp:52
static const TextLogLevel Critical
Designates catastrophic failures.
Definition text_log_level.hpp:37
static const TextLogLevel Error
Designates very serious errors.
Definition text_log_level.hpp:40

Member Function Documentation

◆ with_level()

TextLog rerun::archetypes::TextLog::with_level ( rerun::components::TextLogLevel  _level) &&
inline

The verbosity level of the message.

This can be used to filter the log messages in the Rerun Viewer.

Member Data Documentation

◆ level

std::optional<rerun::components::TextLogLevel> rerun::archetypes::TextLog::level

The verbosity level of the message.

This can be used to filter the log messages in the Rerun Viewer.


The documentation for this struct was generated from the following file: