Rerun C++ SDK
Loading...
Searching...
No Matches
log_sink.hpp
1#pragma once
2
3#include <string_view>
4
5struct rr_log_sink;
6
7namespace rerun {
8 struct LogSink;
9
10 /// Log sink which streams messages to a gRPC server.
11 ///
12 /// The behavior of this sink is the same as the one set by `RecordingStream::connect_grpc`.
13 struct GrpcSink {
14 /// A Rerun gRPC URL.
15 ///
16 /// The scheme must be one of `rerun://`, `rerun+http://`, or `rerun+https://`,
17 /// and the pathname must be `/proxy`.
18 ///
19 /// The default is `rerun+http://127.0.0.1:9876/proxy`.
20 std::string_view url = "rerun+http://127.0.0.1:9876/proxy";
21
22 inline operator LogSink() const;
23 };
24
25 /// Log sink which writes messages to a file.
26 struct FileSink {
27 /// Path to the output file.
28 std::string_view path;
29
30 inline operator LogSink() const;
31 };
32
33 /// A sink for log messages.
34 ///
35 /// See specific log sink types for more information:
36 /// * `GrpcSink`
37 /// * `FileSink`
38 struct LogSink {
39 enum class Kind {
40 Grpc = 0,
41 File = 1,
42 };
43
44 Kind kind;
45
46 union {
47 GrpcSink grpc;
48 FileSink file;
49 };
50 };
51
52 inline GrpcSink::operator LogSink() const {
53 LogSink sink{};
54 sink.kind = LogSink::Kind::Grpc;
55 sink.grpc = *this;
56 return sink;
57 }
58
59 inline FileSink::operator LogSink() const {
60 LogSink sink{};
61 sink.kind = LogSink::Kind::File;
62 sink.file = *this;
63 return sink;
64 }
65
66 namespace detail {
67 rr_log_sink to_rr_log_sink(LogSink sink);
68 }
69} // namespace rerun
All Rerun C++ types and functions are in the rerun namespace or one of its nested namespaces.
Definition rerun.hpp:23
Log sink which writes messages to a file.
Definition log_sink.hpp:26
std::string_view path
Path to the output file.
Definition log_sink.hpp:28
Log sink which streams messages to a gRPC server.
Definition log_sink.hpp:13
std::string_view url
A Rerun gRPC URL.
Definition log_sink.hpp:20
A sink for log messages.
Definition log_sink.hpp:38