Public Types | Public Member Functions | Private Attributes | List of all members
spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex > Class Template Referencefinal

#include <stdout_sinks.h>

Inheritance diagram for spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >:
spdlog::sinks::sink

Public Types

using mutex_t = typename ConsoleMutex::mutex_t
 

Public Member Functions

 stdout_sink ()
 
 ~stdout_sink () override=default
 
 stdout_sink (const stdout_sink &other)=delete
 
stdout_sinkoperator= (const stdout_sink &other)=delete
 
void log (const details::log_msg &msg) override
 
void flush () override
 
void set_pattern (const std::string &pattern) override
 
void set_formatter (std::unique_ptr< spdlog::formatter > sink_formatter) override
 
- 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
 

Private Attributes

mutex_tmutex_
 
FILE * file_
 

Additional Inherited Members

- Protected Attributes inherited from spdlog::sinks::sink
level_t level_
 
std::unique_ptr< spdlog::formatterformatter_
 

Detailed Description

template<typename TargetStream, typename ConsoleMutex>
class spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >

Definition at line 24 of file stdout_sinks.h.

Member Typedef Documentation

template<typename TargetStream , typename ConsoleMutex >
using spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >::mutex_t = typename ConsoleMutex::mutex_t

Definition at line 27 of file stdout_sinks.h.

Constructor & Destructor Documentation

template<typename TargetStream , typename ConsoleMutex >
spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >::stdout_sink ( )
inline
template<typename TargetStream , typename ConsoleMutex >
spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >::~stdout_sink ( )
overridedefault
template<typename TargetStream , typename ConsoleMutex >
spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >::stdout_sink ( const stdout_sink< TargetStream, ConsoleMutex > &  other)
delete

Member Function Documentation

template<typename TargetStream , typename ConsoleMutex >
void spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >::flush ( )
inlineoverridevirtual

Implements spdlog::sinks::sink.

Definition at line 47 of file stdout_sinks.h.

48  {
49  std::lock_guard<mutex_t> lock(mutex_);
50  fflush(file_);
51  }
template<typename TargetStream , typename ConsoleMutex >
void spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >::log ( const details::log_msg msg)
inlineoverridevirtual

Implements spdlog::sinks::sink.

Definition at line 38 of file stdout_sinks.h.

39  {
40  std::lock_guard<mutex_t> lock(mutex_);
41  fmt::memory_buffer formatted;
42  formatter_->format(msg, formatted);
43  fwrite(formatted.data(), sizeof(char), formatted.size(), file_);
44  fflush(TargetStream::stream());
45  }
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
template<typename TargetStream , typename ConsoleMutex >
stdout_sink& spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >::operator= ( const stdout_sink< TargetStream, ConsoleMutex > &  other)
delete
template<typename TargetStream , typename ConsoleMutex >
void spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >::set_formatter ( std::unique_ptr< spdlog::formatter sink_formatter)
inlineoverridevirtual

Implements spdlog::sinks::sink.

Definition at line 59 of file stdout_sinks.h.

60  {
61  std::lock_guard<mutex_t> lock(mutex_);
62  formatter_ = std::move(sink_formatter);
63  }
std::unique_ptr< spdlog::formatter > formatter_
Definition: sink.h:55
def move(depos, offset)
Definition: depos.py:107
template<typename TargetStream , typename ConsoleMutex >
void spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >::set_pattern ( const std::string pattern)
inlineoverridevirtual

Implements spdlog::sinks::sink.

Definition at line 53 of file stdout_sinks.h.

54  {
55  std::lock_guard<mutex_t> lock(mutex_);
56  formatter_ = std::unique_ptr<spdlog::formatter>(new pattern_formatter(pattern));
57  }
std::unique_ptr< spdlog::formatter > formatter_
Definition: sink.h:55
std::string pattern
Definition: regex_t.cc:33

Member Data Documentation

template<typename TargetStream , typename ConsoleMutex >
FILE* spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >::file_
private

Definition at line 67 of file stdout_sinks.h.

template<typename TargetStream , typename ConsoleMutex >
mutex_t& spdlog::sinks::stdout_sink< TargetStream, ConsoleMutex >::mutex_
private

Definition at line 66 of file stdout_sinks.h.


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