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 = rerun::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 (const TextLog &other)=default
 
TextLogoperator= (const TextLog &other)=default
 
TextLogoperator= (TextLog &&other)=default
 
 TextLog (rerun::components::Text _text)
 
TextLog with_text (const rerun::components::Text &_text) &&
 The body of the message.
 
TextLog with_many_text (const Collection< rerun::components::Text > &_text) &&
 This method makes it possible to pack multiple text in a single component batch.
 
TextLog with_level (const rerun::components::TextLogLevel &_level) &&
 The verbosity level of the message.
 
TextLog with_many_level (const Collection< rerun::components::TextLogLevel > &_level) &&
 This method makes it possible to pack multiple level in a single component batch.
 
TextLog with_color (const rerun::components::Color &_color) &&
 Optional color to use for the log line in the Rerun Viewer.
 
TextLog with_many_color (const Collection< rerun::components::Color > &_color) &&
 This method makes it possible to pack multiple color in a single component batch.
 
Collection< ComponentColumncolumns (const Collection< uint32_t > &lengths_)
 Partitions the component data into multiple sub-batches.
 
Collection< ComponentColumncolumns ()
 Partitions the component data into unit-length sub-batches.
 

Static Public Member Functions

static TextLog update_fields ()
 Update only some specific fields of a TextLog.
 
static TextLog clear_fields ()
 Clear all the fields of a TextLog.
 

Public Attributes

std::optional< ComponentBatchtext
 The body of the message.
 
std::optional< ComponentBatchlevel
 The verbosity level of the message.
 
std::optional< ComponentBatchcolor
 Optional color to use for the log line in the Rerun Viewer.
 

Static Public Attributes

static constexpr const char IndicatorComponentName [] = "rerun.components.TextLogIndicator"
 
static constexpr const char ArchetypeName [] = "rerun.archetypes.TextLog"
 The name of the archetype as used in ComponentDescriptors.
 
static constexpr auto Descriptor_text
 ComponentDescriptor for the text field.
 
static constexpr auto Descriptor_level
 ComponentDescriptor for the level field.
 
static constexpr auto Descriptor_color
 ComponentDescriptor for the color field.
 

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:60
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 &... as_components) const
Logs one or more archetype and/or component batches.
Definition recording_stream.hpp:361
Archetype: A log entry in a text log, comprised of a text body and its log level.
Definition text_log.hpp:81
TextLog with_level(const rerun::components::TextLogLevel &_level) &&
The verbosity level of the message.
Definition text_log.hpp:152
std::optional< ComponentBatch > level
The verbosity level of the message.
Definition text_log.hpp:88
Component: The severity level of a text log message.
Definition text_log_level.hpp:26
static RERUN_SDK_EXPORT const TextLogLevel Error
Designates very serious errors.
Definition text_log_level.hpp:34
static RERUN_SDK_EXPORT const TextLogLevel Debug
Designates lower priority information.
Definition text_log_level.hpp:43
static RERUN_SDK_EXPORT const TextLogLevel Info
Designates useful information.
Definition text_log_level.hpp:40
static RERUN_SDK_EXPORT const TextLogLevel Trace
Designates very low priority, often extremely verbose, information.
Definition text_log_level.hpp:46
static RERUN_SDK_EXPORT const TextLogLevel Critical
Designates catastrophic failures.
Definition text_log_level.hpp:31
static RERUN_SDK_EXPORT const TextLogLevel Warning
Designates hazardous situations.
Definition text_log_level.hpp:37

Member Function Documentation

◆ with_many_text()

TextLog rerun::archetypes::TextLog::with_many_text ( const Collection< rerun::components::Text > &  _text) &&
inline

This method makes it possible to pack multiple text in a single component batch.

This only makes sense when used in conjunction with columns. with_text should be used when logging a single row's worth of data.

◆ with_level()

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

The verbosity level of the message.

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

◆ with_many_level()

TextLog rerun::archetypes::TextLog::with_many_level ( const Collection< rerun::components::TextLogLevel > &  _level) &&
inline

This method makes it possible to pack multiple level in a single component batch.

This only makes sense when used in conjunction with columns. with_level should be used when logging a single row's worth of data.

◆ with_many_color()

TextLog rerun::archetypes::TextLog::with_many_color ( const Collection< rerun::components::Color > &  _color) &&
inline

This method makes it possible to pack multiple color in a single component batch.

This only makes sense when used in conjunction with columns. with_color should be used when logging a single row's worth of data.

◆ columns() [1/2]

Collection< ComponentColumn > rerun::archetypes::TextLog::columns ( const Collection< uint32_t > &  lengths_)

Partitions the component data into multiple sub-batches.

Specifically, this transforms the existing ComponentBatch data into ComponentColumns instead, via ComponentBatch::partitioned.

This makes it possible to use RecordingStream::send_columns to send columnar data directly into Rerun.

The specified lengths must sum to the total length of the component batch.

◆ columns() [2/2]

Collection< ComponentColumn > rerun::archetypes::TextLog::columns ( )

Partitions the component data into unit-length sub-batches.

This is semantically similar to calling columns with std::vector<uint32_t>(n, 1), where n is automatically guessed.

Member Data Documentation

◆ level

std::optional<ComponentBatch> rerun::archetypes::TextLog::level

The verbosity level of the message.

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

◆ Descriptor_text

constexpr auto rerun::archetypes::TextLog::Descriptor_text
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "text", Loggable<rerun::components::Text>::Descriptor.component_name
)
static constexpr const char ArchetypeName[]
The name of the archetype as used in ComponentDescriptors.
Definition text_log.hpp:99

ComponentDescriptor for the text field.

◆ Descriptor_level

constexpr auto rerun::archetypes::TextLog::Descriptor_level
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "level",
Loggable<rerun::components::TextLogLevel>::Descriptor.component_name
)

ComponentDescriptor for the level field.

◆ Descriptor_color

constexpr auto rerun::archetypes::TextLog::Descriptor_color
staticconstexpr
Initial value:
= ComponentDescriptor(
ArchetypeName, "color", Loggable<rerun::components::Color>::Descriptor.component_name
)

ComponentDescriptor for the color field.


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