Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
spdlog::sinks::ostream_sink< Mutex > Class Template Referencefinal

#include <ostream_sink.h>

Inheritance diagram for spdlog::sinks::ostream_sink< Mutex >:
spdlog::sinks::base_sink< Mutex > spdlog::sinks::sink

Public Member Functions

 ostream_sink (std::ostream &os, bool force_flush=false)
 
 ostream_sink (const ostream_sink &)=delete
 
ostream_sinkoperator= (const ostream_sink &)=delete
 
- Public Member Functions inherited from spdlog::sinks::base_sink< Mutex >
 base_sink ()=default
 
 base_sink (const base_sink &)=delete
 
base_sinkoperator= (const base_sink &)=delete
 
void log (const details::log_msg &msg) final
 
void flush () final
 
void set_pattern (const std::string &pattern) final
 
void set_formatter (std::unique_ptr< spdlog::formatter > sink_formatter) final
 
- Public Member Functions inherited from spdlog::sinks::sink
 sink ()
 
 sink (std::unique_ptr< spdlog::pattern_formatter > formatter)
 
virtual ~sink ()=default
 
bool should_log (level::level_enum msg_level) const
 
void set_level (level::level_enum log_level)
 
level::level_enum level () const
 

Protected Member Functions

void sink_it_ (const details::log_msg &msg) override
 
void flush_ () override
 
- Protected Member Functions inherited from spdlog::sinks::base_sink< Mutex >
virtual void set_pattern_ (const std::string &pattern)
 
virtual void set_formatter_ (std::unique_ptr< spdlog::formatter > sink_formatter)
 

Protected Attributes

std::ostream & ostream_
 
bool force_flush_
 
- Protected Attributes inherited from spdlog::sinks::base_sink< Mutex >
Mutex mutex_
 
- Protected Attributes inherited from spdlog::sinks::sink
level_t level_
 
std::unique_ptr< spdlog::formatterformatter_
 

Detailed Description

template<typename Mutex>
class spdlog::sinks::ostream_sink< Mutex >

Definition at line 21 of file ostream_sink.h.

Constructor & Destructor Documentation

template<typename Mutex >
spdlog::sinks::ostream_sink< Mutex >::ostream_sink ( std::ostream &  os,
bool  force_flush = false 
)
inlineexplicit

Definition at line 24 of file ostream_sink.h.

25  : ostream_(os)
26  , force_flush_(force_flush)
27  {
28  }
template<typename Mutex >
spdlog::sinks::ostream_sink< Mutex >::ostream_sink ( const ostream_sink< Mutex > &  )
delete

Member Function Documentation

template<typename Mutex >
void spdlog::sinks::ostream_sink< Mutex >::flush_ ( )
inlineoverrideprotectedvirtual

Implements spdlog::sinks::base_sink< Mutex >.

Definition at line 44 of file ostream_sink.h.

45  {
46  ostream_.flush();
47  }
template<typename Mutex >
ostream_sink& spdlog::sinks::ostream_sink< Mutex >::operator= ( const ostream_sink< Mutex > &  )
delete
template<typename Mutex >
void spdlog::sinks::ostream_sink< Mutex >::sink_it_ ( const details::log_msg msg)
inlineoverrideprotectedvirtual

Implements spdlog::sinks::base_sink< Mutex >.

Definition at line 33 of file ostream_sink.h.

34  {
35  fmt::memory_buffer formatted;
36  sink::formatter_->format(msg, formatted);
37  ostream_.write(formatted.data(), static_cast<std::streamsize>(formatted.size()));
38  if (force_flush_)
39  {
40  ostream_.flush();
41  }
42  }
basic_memory_buffer< char > memory_buffer
Definition: format.h:553
void msg(const char *fmt,...)
Definition: message.cpp:107
std::unique_ptr< spdlog::formatter > formatter_
Definition: sink.h:55

Member Data Documentation

template<typename Mutex >
bool spdlog::sinks::ostream_sink< Mutex >::force_flush_
protected

Definition at line 50 of file ostream_sink.h.

template<typename Mutex >
std::ostream& spdlog::sinks::ostream_sink< Mutex >::ostream_
protected

Definition at line 49 of file ostream_sink.h.


The documentation for this class was generated from the following file: