ostream_sink.h
Go to the documentation of this file.
1 //
2 // Copyright(c) 2015 Gabi Melman.
3 // Distributed under the MIT License (http://opensource.org/licenses/MIT)
4 //
5 
6 #pragma once
7 
10 
11 #include <ostream>
12 #include <mutex>
13 
14 namespace spdlog
15 {
16 namespace sinks
17 {
18 template<class Mutex>
19 class ostream_sink: public base_sink<Mutex>
20 {
21 public:
22  explicit ostream_sink(std::ostream& os, bool force_flush=false) :_ostream(os), _force_flush(force_flush) {}
23  ostream_sink(const ostream_sink&) = delete;
24  ostream_sink& operator=(const ostream_sink&) = delete;
25  virtual ~ostream_sink() = default;
26 
27 protected:
28  void _sink_it(const details::log_msg& msg) override
29  {
30  _ostream.write(msg.formatted.data(), msg.formatted.size());
31  if (_force_flush)
32  _ostream.flush();
33  }
34 
35  void _flush() override
36  {
37  _ostream.flush();
38  }
39 
40  std::ostream& _ostream;
42 };
43 
46 }
47 }
virtual ~ostream_sink()=default
ostream_sink(std::ostream &os, bool force_flush=false)
Definition: ostream_sink.h:22
ostream_sink< details::null_mutex > ostream_sink_st
Definition: ostream_sink.h:45
void _sink_it(const details::log_msg &msg) override
Definition: ostream_sink.h:28
const Char * data() const FMT_NOEXCEPT
Definition: format.h:2866
ostream_sink< std::mutex > ostream_sink_mt
Definition: ostream_sink.h:44
ostream_sink & operator=(const ostream_sink &)=delete
fmt::MemoryWriter formatted
Definition: log_msg.h:46
std::size_t size() const
Definition: format.h:2857


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:07