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 /// The minimum time the SDK will wait during a flush before potentially
23 /// dropping data if progress is not being made. Passing a negative value indicates no timeout,
24 /// and can cause a call to `flush` to block indefinitely.
25 float flush_timeout_sec = 3.0;
26
27 inline operator LogSink() const;
28 };
29
30 /// Log sink which writes messages to a file.
31 struct FileSink {
32 /// Path to the output file.
33 std::string_view path;
34
35 inline operator LogSink() const;
36 };
37
38 /// A sink for log messages.
39 ///
40 /// See specific log sink types for more information:
41 /// * `GrpcSink`
42 /// * `FileSink`
43 struct LogSink {
44 enum class Kind {
45 Grpc = 0,
46 File = 1,
47 };
48
49 Kind kind;
50
51 union {
52 GrpcSink grpc;
53 FileSink file;
54 };
55 };
56
57 inline GrpcSink::operator LogSink() const {
58 LogSink sink{};
59 sink.kind = LogSink::Kind::Grpc;
60 sink.grpc = *this;
61 return sink;
62 }
63
64 inline FileSink::operator LogSink() const {
65 LogSink sink{};
66 sink.kind = LogSink::Kind::File;
67 sink.file = *this;
68 return sink;
69 }
70
71 namespace detail {
72 rr_log_sink to_rr_log_sink(LogSink sink);
73 };
74}; // 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:31
std::string_view path
Path to the output file.
Definition log_sink.hpp:33
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
float flush_timeout_sec
The minimum time the SDK will wait during a flush before potentially dropping data if progress is not...
Definition log_sink.hpp:25
A sink for log messages.
Definition log_sink.hpp:43