11#ifndef CPPTRAIL_OSTREAM_LOGGER_H
12#define CPPTRAIL_OSTREAM_LOGGER_H
14#if __cplusplus >= 202002L
31 template<
typename char_t>
40 std::basic_ostream<char_t> &oOstream,
41 const bool bUseLocalTime =
true
43 std::reference_wrapper<std::basic_ostream<char_t> >(oOstream),
56 std::reference_wrapper<std::basic_ostream<char_t> > oOstream,
57 const bool bUseLocalTime =
true
59 std::make_shared<Impl>(oOstream, bUseLocalTime)
89 std::reference_wrapper<std::basic_ostream<char_t> > oOstream,
90 const bool bUseLocalTime
91 ) : m_oOstream(oOstream),
92 m_bUseLocalTime(bUseLocalTime) {
115 void work(message_type oMessage)
override;
121 Status serviceStatus()
override {
126 void serviceStart()
override {
130 void serviceStop()
override {
135 std::reference_wrapper<std::basic_ostream<char_t> > m_oOstream;
138 bool m_bUseLocalTime;
152#if __cplusplus >= 202002L
216 template<
typename char_t>
225 std::basic_ostream<char_t> &oOstream,
226 const bool bUseLocalTime =
true
228 std::reference_wrapper<std::basic_ostream<char_t> >(oOstream),
241 std::reference_wrapper<std::basic_ostream<char_t> > oOstream,
242 const bool bUseLocalTime =
true
244 std::make_shared<Impl>(oOstream, bUseLocalTime)
260 std::reference_wrapper<std::basic_ostream<char_t> > oOstream,
261 const bool bUseLocalTime,
262 std::size_t nMaxEntryCount,
263 bool bThrowOnOverflow
265 std::make_shared<Impl>(
304 std::reference_wrapper<std::basic_ostream<char_t> > oOstream,
305 const bool bUseLocalTime
306 ) : m_oOstream(oOstream),
307 m_bUseLocalTime(bUseLocalTime) {
320 std::reference_wrapper<std::basic_ostream<char_t> > oOstream,
321 const bool bUseLocalTime,
322 std::size_t nMaxEntryCount,
323 bool bThrowOnOverflow
328 ), m_oOstream(oOstream),
329 m_bUseLocalTime(bUseLocalTime) {
365 void work(message_type oMessage)
override;
371 Status serviceStatus()
override {
376 void serviceStart()
override {
380 void serviceStop()
override {
385 std::reference_wrapper<std::basic_ostream<char_t> > m_oOstream;
387 bool m_bUseLocalTime;
401#if __cplusplus >= 202002L
455 template<
typename char_t>
456 void BasicSyncOstreamLogger<char_t>::Impl::work(
457 message_type oMessage
460 std::basic_ostream<char_t> &oOstream = m_oOstream.get();
462#if __cplusplus >= 202002L
464 Detail::toRfc3339<char_t>(oOstream, this->m_bUseLocalTime);
468 oOstream << oMessage.stealLevel();
469 oOstream.put(
static_cast<char_t
>(
' '));
470 oOstream << oMessage.stealString();
471 oOstream.put(
static_cast<char_t
>(
'\n'));
477 template<
typename char_t>
478 void BasicAsyncOstreamLogger<char_t>::Impl::work(
479 message_type oMessage
482 std::basic_ostream<char_t> &oOstream = m_oOstream.get();
484#if __cplusplus >= 202002L
486 Detail::toRfc3339<char_t>(oOstream, this->m_bUseLocalTime);
490 oOstream << oMessage.stealLevel();
493 oOstream.put(
static_cast<char_t
>(
' '));
494 oOstream << oMessage.stealString();
495 oOstream.put(
static_cast<char_t
>(
'\n'));
A specialized asynchronous logger handle targeting the standard error stream (std::cerr).
Definition ostream_logger.h:446
AsyncCerrLogger()
Constructs a CerrAsyncLogger initialized with the std::cerr sink.
Definition ostream_logger.h:451
A specialized asynchronous logger handle targeting the standard output stream (std::cout).
Definition ostream_logger.h:425
AsyncCoutLogger()
Constructs a CoutAsyncLogger initialized with the std::cout sink.
Definition ostream_logger.h:430
An asynchronous logger template utilizing background worker threads and object recycling....
Definition async_logger.h:53
void join() final
Blocks until all background activity (workers and killer threads) has ceased.
Definition async_logger.h:471
BasicAsyncLoggerImpl()
Default constructor.
Definition async_logger.h:69
void stop() final
Synchronously shuts down the worker pool and the service.
Definition async_logger.h:413
An asynchronous logger handle that dispatches output to a C++ standard stream.
Definition ostream_logger.h:217
BasicAsyncOstreamLogger(std::basic_ostream< char_t > &oOstream, const bool bUseLocalTime=true)
Constructs a AsyncLogger from a raw stream reference.
Definition ostream_logger.h:224
BasicAsyncOstreamLogger(std::reference_wrapper< std::basic_ostream< char_t > > oOstream, const bool bUseLocalTime, std::size_t nMaxEntryCount, bool bThrowOnOverflow)
Constructs a AsyncLogger from a reference_wrapper.
Definition ostream_logger.h:259
BasicAsyncOstreamLogger(std::reference_wrapper< std::basic_ostream< char_t > > oOstream, const bool bUseLocalTime=true)
Constructs a AsyncLogger from a reference_wrapper.
Definition ostream_logger.h:240
char_t char_type
Alias for the underlying character type used by this logger.
Definition base_logger.h:31
std::basic_string< char_type > string_type
Alias for the basic_string type associated with this logger's encoding.
Definition base_logger.h:34
A high-level handle for logging operations.
Definition base_logger.h:121
Container for log message implementations.
Definition message.h:76
A synchronous, thread-safe logger implementation template. This class ensures that every log call is ...
Definition sync_logger.h:29
void join() override
Waits for the asynchronous end of the shutdown sequence.
Definition sync_logger.h:110
void stop() final
Stops the logger service.
Definition sync_logger.h:91
A synchronous logger handle that directs output to a C++ standard output stream.
Definition ostream_logger.h:32
BasicSyncOstreamLogger(std::basic_ostream< char_t > &oOstream, const bool bUseLocalTime=true)
Constructs a logger from a raw stream reference.
Definition ostream_logger.h:39
BasicSyncOstreamLogger(std::reference_wrapper< std::basic_ostream< char_t > > oOstream, const bool bUseLocalTime=true)
Constructs a logger from a reference_wrapper.
Definition ostream_logger.h:55
A specialized logger handle targeting the standard error stream (std::cerr).
Definition ostream_logger.h:193
SyncCerrLogger()
Constructs a new CerrLogger.
Definition ostream_logger.h:199
A specialized logger handle targeting the standard output stream (std::cout).
Definition ostream_logger.h:174
SyncCoutLogger()
Constructs a new CoutLogger.
Definition ostream_logger.h:180
High-level wrapper for the CppTrail logging system.
Root namespace for the CppTrail logging library.
Definition async_logger.h:24
Status
Represents the current operational state of a Logger implementation.
Definition def.h:31
@ TRASCENDENT
The logger operates outside standard lifecycle management.