26
26
#include < boost/beast/core/string.hpp>
27
27
#include < boost/filesystem.hpp>
28
28
29
+ #include < boost/lockfree/queue.hpp>
30
+
29
31
#include < array>
30
32
#include < atomic>
31
33
#include < chrono>
@@ -74,10 +76,10 @@ class Logs
74
76
operator =(Sink const &) = delete ;
75
77
76
78
void
77
- write (beast::severities::Severity level, std::string_view text, beast::Journal::MessagePoolNode owner = nullptr ) override ;
79
+ write (beast::severities::Severity level, beast::Journal::StringBuffer text ) override ;
78
80
79
81
void
80
- writeAlways (beast::severities::Severity level, std::string_view text, beast::Journal::MessagePoolNode owner = nullptr )
82
+ writeAlways (beast::severities::Severity level, beast::Journal::StringBuffer text )
81
83
override ;
82
84
};
83
85
@@ -135,7 +137,7 @@ class Logs
135
137
Does nothing if there is no associated system file.
136
138
*/
137
139
void
138
- write (std::string& & str);
140
+ write (std::string const & str);
139
141
140
142
/* * @} */
141
143
@@ -156,7 +158,7 @@ class Logs
156
158
157
159
// Batching members
158
160
mutable std::mutex batchMutex_;
159
- beast ::lockfree::queue<std::string > messages_;
161
+ boost ::lockfree::queue<beast::Journal::StringBuffer, boost::lockfree::capacity< 100 > > messages_;
160
162
static constexpr size_t BATCH_BUFFER_SIZE = 64 * 1024 ; // 64KB buffer
161
163
std::array<char , BATCH_BUFFER_SIZE> batchBuffer_{};
162
164
std::span<char > writeBuffer_; // Points to available write space
@@ -217,8 +219,7 @@ class Logs
217
219
write (
218
220
beast::severities::Severity level,
219
221
std::string const & partition,
220
- std::string_view text,
221
- beast::Journal::MessagePoolNode owner,
222
+ beast::Journal::StringBuffer text,
222
223
bool console);
223
224
224
225
std::string
@@ -280,12 +281,16 @@ class Logs
280
281
// Wraps a Journal::Stream to skip evaluation of
281
282
// expensive argument lists if the stream is not active.
282
283
#ifndef JLOG
284
+ #define JLOG_JOIN_ (a,b ) a##b
285
+ #define JLOG_JOIN (a,b ) JLOG_JOIN_(a,b)
286
+ #define JLOG_UNIQUE (base ) JLOG_JOIN(base, __LINE__) // line-based unique name
287
+
283
288
#define JLOG (x ) \
284
- if (!x) \
285
- { \
286
- } \
287
- else \
288
- x
289
+ if (auto JLOG_UNIQUE (stream) = (x); !JLOG_UNIQUE(stream)) \
290
+ { \
291
+ } \
292
+ else \
293
+ JLOG_UNIQUE (stream)
289
294
#endif
290
295
291
296
#ifndef CLOG
0 commit comments