Rerun C++ SDK
Loading...
Searching...
No Matches
text_log.hpp
1// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs
2// Based on "crates/store/re_types/definitions/rerun/archetypes/text_log.fbs".
3
4#pragma once
5
6#include "../collection.hpp"
7#include "../compiler_utils.hpp"
8#include "../component_batch.hpp"
9#include "../components/color.hpp"
10#include "../components/text.hpp"
11#include "../components/text_log_level.hpp"
12#include "../indicator_component.hpp"
13#include "../result.hpp"
14
15#include <cstdint>
16#include <optional>
17#include <utility>
18#include <vector>
19
20namespace rerun::archetypes {
21 /// **Archetype**: A log entry in a text log, comprised of a text body and its log level.
22 ///
23 /// ## Example
24 ///
25 /// ### text_log_integration:
26 /// ![image](https://static.rerun.io/text_log_integration/9737d0c986325802a9885499d6fcc773b1736488/full.png)
27 ///
28 /// ```cpp
29 /// #include <loguru.hpp>
30 /// #include <rerun.hpp>
31 ///
32 /// void loguru_to_rerun(void* user_data, const loguru::Message& message) {
33 /// // NOTE: `rerun::RecordingStream` is thread-safe.
34 /// const rerun::RecordingStream* rec = reinterpret_cast<const rerun::RecordingStream*>(user_data);
35 ///
36 /// rerun::TextLogLevel level;
37 /// if (message.verbosity == loguru::Verbosity_FATAL) {
38 /// level = rerun::TextLogLevel::Critical;
39 /// } else if (message.verbosity == loguru::Verbosity_ERROR) {
40 /// level = rerun::TextLogLevel::Error;
41 /// } else if (message.verbosity == loguru::Verbosity_WARNING) {
42 /// level = rerun::TextLogLevel::Warning;
43 /// } else if (message.verbosity == loguru::Verbosity_INFO) {
44 /// level = rerun::TextLogLevel::Info;
45 /// } else if (message.verbosity == loguru::Verbosity_1) {
46 /// level = rerun::TextLogLevel::Debug;
47 /// } else if (message.verbosity == loguru::Verbosity_2) {
48 /// level = rerun::TextLogLevel::Trace;
49 /// } else {
50 /// level = rerun::TextLogLevel(std::to_string(message.verbosity));
51 /// }
52 ///
53 /// rec->log(
54 /// "logs/handler/text_log_integration",
55 /// rerun::TextLog(message.message).with_level(level)
56 /// );
57 /// }
58 ///
59 /// int main() {
60 /// const auto rec = rerun::RecordingStream("rerun_example_text_log_integration");
61 /// rec.spawn().exit_on_failure();
62 ///
63 /// // Log a text entry directly:
64 /// rec.log(
65 /// "logs",
66 /// rerun::TextLog("this entry has loglevel TRACE").with_level(rerun::TextLogLevel::Trace)
67 /// );
68 ///
69 /// loguru::add_callback(
70 /// "rerun",
71 /// loguru_to_rerun,
72 /// const_cast<void*>(reinterpret_cast<const void*>(&rec)),
73 /// loguru::Verbosity_INFO
74 /// );
75 ///
76 /// LOG_F(INFO, "This INFO log got added through the standard logging interface");
77 ///
78 /// loguru::remove_callback("rerun"); // we need to do this before `rec` goes out of scope
79 /// }
80 /// ```
81 struct TextLog {
82 /// The body of the message.
84
85 /// The verbosity level of the message.
86 ///
87 /// This can be used to filter the log messages in the Rerun Viewer.
88 std::optional<rerun::components::TextLogLevel> level;
89
90 /// Optional color to use for the log line in the Rerun Viewer.
91 std::optional<rerun::components::Color> color;
92
93 public:
94 static constexpr const char IndicatorComponentName[] = "rerun.components.TextLogIndicator";
95
96 /// Indicator component, used to identify the archetype when converting to a list of components.
98
99 public:
100 TextLog() = default;
101 TextLog(TextLog&& other) = default;
102
103 explicit TextLog(rerun::components::Text _text) : text(std::move(_text)) {}
104
105 /// The verbosity level of the message.
106 ///
107 /// This can be used to filter the log messages in the Rerun Viewer.
109 level = std::move(_level);
110 // See: https://github.com/rerun-io/rerun/issues/4027
111 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
112 }
113
114 /// Optional color to use for the log line in the Rerun Viewer.
116 color = std::move(_color);
117 // See: https://github.com/rerun-io/rerun/issues/4027
118 RR_WITH_MAYBE_UNINITIALIZED_DISABLED(return std::move(*this);)
119 }
120 };
121
122} // namespace rerun::archetypes
123
124namespace rerun {
125 /// \private
126 template <typename T>
127 struct AsComponents;
128
129 /// \private
130 template <>
131 struct AsComponents<archetypes::TextLog> {
132 /// Serialize all set component batches.
133 static Result<std::vector<ComponentBatch>> serialize(const archetypes::TextLog& archetype);
134 };
135} // namespace rerun
All built-in archetypes. See Types in the Rerun manual.
Definition rerun.hpp:77
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
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_color(rerun::components::Color _color) &&
Optional color to use for the log line in the Rerun Viewer.
Definition text_log.hpp:115
std::optional< rerun::components::Color > color
Optional color to use for the log line in the Rerun Viewer.
Definition text_log.hpp:91
rerun::components::Text text
The body of the message.
Definition text_log.hpp:83
TextLog with_level(rerun::components::TextLogLevel _level) &&
The verbosity level of the message.
Definition text_log.hpp:108
Component: An RGBA color with unmultiplied/separate alpha, in sRGB gamma space with linear alpha.
Definition color.hpp:18
Indicator component used by archetypes when converting them to component lists.
Definition indicator_component.hpp:32
Component: The severity level of a text log message.
Definition text_log_level.hpp:26
Component: A string of text, e.g. for labels and text documents.
Definition text.hpp:17