fix8  version 1.4.0
Open Source C++ FIX Framework
logger.hpp
Go to the documentation of this file.
1 //-------------------------------------------------------------------------------------------------
2 /*
3 
4 Fix8 is released under the GNU LESSER GENERAL PUBLIC LICENSE Version 3.
5 
6 Fix8 Open Source FIX Engine.
7 Copyright (C) 2010-16 David L. Dight <fix@fix8.org>
8 
9 Fix8 is free software: you can redistribute it and / or modify it under the terms of the
10 GNU Lesser General Public License as published by the Free Software Foundation, either
11 version 3 of the License, or (at your option) any later version.
12 
13 Fix8 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
14 even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 
16 You should have received a copy of the GNU Lesser General Public License along with Fix8.
17 If not, see <http://www.gnu.org/licenses/>.
18 
19 BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO
20 THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE
21 COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
22 KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO
24 THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE,
25 YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
26 
27 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT
28 HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED
29 ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
30 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
31 NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR
32 THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
33 HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
34 
35 */
36 //-------------------------------------------------------------------------------------------------
37 #ifndef FIX8_LOGGER_HPP_
38 #define FIX8_LOGGER_HPP_
39 
40 //-------------------------------------------------------------------------------------------------
41 #include <list>
42 #include <Poco/Net/IPAddress.h>
43 #include <Poco/Net/DatagramSocket.h>
44 
45 //-------------------------------------------------------------------------------------------------
46 namespace FIX8 {
47 
48 //-------------------------------------------------------------------------------------------------
50 class fdoutbuf : public std::streambuf
51 {
52 protected:
53  int fd;
54 
55  virtual int_type overflow(int_type c)
56  {
57  if (c != traits_type::eof())
58  {
59  char z(c);
60  if (write(fd, &z, 1) != 1)
61  return traits_type::eof();
62  }
63  return c;
64  }
65 
66  virtual std::streamsize xsputn(const char *s, std::streamsize num)
67  {
68  return write (fd, s, num);
69  }
70 
71 public:
72  fdoutbuf(int _fd) : fd(_fd) {}
73  virtual ~fdoutbuf () {}
74 };
75 
77 class fptrostream : public std::ostream
78 {
79  FILE *fptr_;
80 
81 protected:
83 
84 public:
87  fptrostream(FILE *fptr)
88  : std::ostream(&buf_), fptr_(fptr), buf_(fileno(fptr)) {}
89 
91  virtual ~fptrostream ()
92  {
93 #ifdef _MSC_VER
94  _pclose(fptr_);
95 #else
96  pclose(fptr_);
97 #endif
98  }
99 
102  int getfileno() { return fileno(fptr_); }
103 };
104 
105 //-------------------------------------------------------------------------------------------------
107 class bcoutbuf : public std::streambuf
108 {
109 protected:
110  Poco::Net::DatagramSocket *_sock;
111 
112  virtual int_type overflow(int_type c)
113  {
114  if (c != traits_type::eof())
115  {
116  char z(c);
117  _sock->sendBytes(&z, 1);
118  }
119  return c;
120  }
121 
122  virtual std::streamsize xsputn(const char *s, std::streamsize num)
123  {
124  _sock->sendBytes(s, num);
125  return num;
126  }
127 
128 public:
129  bcoutbuf(Poco::Net::DatagramSocket *sock) : _sock(sock) {}
130  virtual ~bcoutbuf() { _sock->close(); delete _sock; }
131 };
132 
134 class bcostream : public std::ostream
135 {
136 protected:
138 
139 public:
142  bcostream(Poco::Net::DatagramSocket *sock) : std::ostream(&buf_), buf_(sock) {}
143 
145  virtual ~bcostream() {}
146 };
147 
148 //-------------------------------------------------------------------------------------------------
149 class Tickval;
150 
151 //-------------------------------------------------------------------------------------------------
153 class Logger
154 {
156  std::list<std::string> _buffer;
157 
158 public:
159  enum Level { Debug, Info, Warn, Error, Fatal };
160 #ifndef _MSC_VER
162 #else
163  static const int Errors = (1<<Warn|1<<Error|1<<Fatal), All = (1<<Debug|1<<Info|1<<Warn|1<<Error|1<<Fatal);
164 #endif
165  static const int None = 0;
168 #ifndef _MSC_VER
170 #else
171  static const int StdFlags = (1<<sequence|1<<thread|1<<timestamp|1<<level|1<<location);
172 #endif
173  static const int rotation_default = 5, max_rotation = 1024;
176  using LogPositions = std::vector<int>;
177 
178 protected:
183  std::string _delim;
184  std::ostream *_ofs = nullptr;
185  size_t _lines = 0;
187 
188  struct LogElement
189  {
191  std::string _str;
193  const char *_fileline;
194  unsigned _val{};
195  Tickval _when{true};
196 
197  LogElement(const thread_id_t tid, const std::string& str, Level level, const char *fl=nullptr, const unsigned val=0)
198  : _tid(tid), _str(str), _level(level), _fileline(fl), _val(val) {}
199  LogElement(const thread_id_t tid, const std::string& str, const unsigned val=0)
200  : _tid(tid), _str(str), _level(Info), _fileline(), _val(val) {}
201  LogElement() : _tid(), _level(Info),_fileline() {}
202  LogElement(const LogElement& from) : _tid(from._tid), _str(from._str), _level(from._level), _fileline(from._fileline),
203  _val(from._val), _when(from._when) {}
205  {
206  if (this != &that)
207  {
208  _tid = that._tid;
209  _str = that._str;
210  _level = that._level;
211  _fileline = that._fileline;
212  _val = that._val;
213  _when = that._when;
214  }
215  return *this;
216  }
217  };
218 
220  unsigned _sequence = 0, _osequence = 0;
221 
222  using ThreadCodes = std::map<thread_id_t, char>;
224 
225  using RevThreadCodes = std::map<char, thread_id_t>;
227 
229  static const Tickval _started;
230 
232 
233 public:
239  Logger(const LogFlags flags, const Levels levels=Levels(All), const std::string delim=" ", const LogPositions positions=LogPositions())
240  : _thread(std::ref(*this)), _flags(flags), _levels(levels), _delim(delim), _positions(positions)
241  {
242  if (_positions.empty()) // setup default order
243  {
244  for (auto ii(mstart); ii != num_flags; ii = Flags(ii + 1))
245  if (_flags & ii)
246  _positions.push_back(ii);
247  }
248 
249  _thread.start();
250  }
251 
253  virtual ~Logger()
254  {
255  stop();
256  delete _ofs;
257  }
258 
262  bool is_loggable(Level level) const { return _levels & level; }
263 
266  void set_levels(Levels levels) { _levels = levels; }
267 
270  void set_flags(LogFlags flags) { _flags = flags; }
271 
274  void set_delimiter(const std::string& delim) { _delim = delim; }
275 
278  void set_positions(const std::vector<int>& positions)
279  {
280  f8_scoped_spin_lock guard(_log_spl);
281  _positions = positions;
282  }
283 
286  virtual std::ostream& get_stream() const { return _ofs ? *_ofs : std::cout; }
287 
294  bool enqueue(const std::string& what, Level lev=Logger::Info, const char *fl=nullptr, const unsigned val=0)
295  {
296  const LogElement le(f8_thread<Logger>::getid(), what, lev, fl, val);
297  return _msg_queue.try_push (le) == 0;
298  }
299 
306  bool send(const std::string& what, Level lev=Logger::Info, const char *fl=nullptr, const unsigned val=0)
307  { return is_loggable(lev) ? enqueue(what, lev, fl, val) : true; }
308 
310  void stop() { _stopping.request_stop(); enqueue(std::string()); _thread.join(); }
311 
315  virtual bool rotate(bool force=false) { return true; }
316 
319  F8API int operator()();
320 
323  F8API virtual void process_logline(LogElement *le);
324 
326  static const std::vector<std::string> _bit_names;
327 
329  static const std::vector<std::string> _level_names;
330 
333  static const Tickval& get_time_started() { return _started; }
334 
338  bool has_flag(const Flags flg) const { return _flags.has(flg); }
339 
343 
345  F8API void purge_thread_codes();
346 
348  F8API virtual void flush();
349 
353 };
354 
355 //-------------------------------------------------------------------------------------------------
357 class FileLogger : public Logger
358 {
359 protected:
360  std::string _pathname;
361  unsigned _rotnum;
362 
363 public:
371  F8API FileLogger(const std::string& pathname, const LogFlags flags, const Levels levels, const std::string delim=" ",
372  const LogPositions positions=LogPositions(), const unsigned rotnum=rotation_default);
373 
375  virtual ~FileLogger() {}
376 
380  F8API virtual bool rotate(bool force=false);
381 };
382 
383 //-------------------------------------------------------------------------------------------------
385 class XmlFileLogger : public FileLogger
386 {
387 
388 public:
396  F8API XmlFileLogger(const std::string& pathname, const LogFlags flags, const Levels levels, const std::string delim=" ",
397  const LogPositions positions=LogPositions(), const unsigned rotnum=rotation_default)
398  : FileLogger(pathname, flags, levels, delim, positions, rotnum)
399  {
400  preamble();
401  }
402 
404  void preamble() { get_stream() << "<?xml version='1.0' encoding='ISO-8859-1'?>" << std::endl << "<fix8>" << std::endl; }
406  void postamble() { get_stream() << "</fix8>" << std::endl; }
407 
409  virtual ~XmlFileLogger() { postamble(); }
410 
413  F8API virtual void process_logline(LogElement *le);
414 };
415 
416 //-------------------------------------------------------------------------------------------------
418 class PipeLogger : public Logger
419 {
420 public:
427  PipeLogger(const std::string& command, const LogFlags flags, const Levels levels, const std::string delim=" ",
428  LogPositions positions=LogPositions());
429 
431  virtual ~PipeLogger() {}
432 };
433 
434 //-------------------------------------------------------------------------------------------------
436 class BCLogger : public Logger
437 {
438  bool _init_ok;
439 
440 public:
447  BCLogger(Poco::Net::DatagramSocket *sock, const LogFlags flags, const Levels levels, const std::string delim=" ",
448  LogPositions positions=LogPositions());
449 
457  BCLogger(const std::string& ip, const unsigned port, const LogFlags flags, const Levels levels,
458  const std::string delim=" ", LogPositions positions=LogPositions());
459 
462  operator void*() { return _init_ok ? this : 0; }
463 
465  virtual ~BCLogger() {}
466 };
467 
468 //-------------------------------------------------------------------------------------------------
469 const size_t max_global_filename_length(1024);
470 
472 
474 template<char *fn>
476 {
478  {
481 #if defined FIX8_BUFFERED_GLOBAL_LOGGING
482  << Logger::buffer
483 #endif
485 
486  return _fl;
487  }
488 
489 public:
492  static void set_global_filename(const std::string& from)
493  { CopyString(from, fn, max_global_filename_length); }
494 
501  static bool log(const std::string& what, Logger::Level lev=Logger::Info, const char *fl=nullptr, unsigned int val=0)
502  { return instance().send(what, lev, fl, val); }
503 
510  static bool enqueue(const std::string& what, Logger::Level lev=Logger::Info, const char *fl=nullptr, unsigned int val=0)
511  { return instance().enqueue(what, lev, fl, val); }
512 
514  static void flush_log() { instance().flush(); }
515 
518  static void set_flags(Logger::LogFlags flags) { instance().set_flags(flags); }
519 
522  static void set_levels(Logger::Levels levels) { instance().set_levels(levels); }
523 
526  static void set_delimiter(const std::string& delim) { instance().set_delimiter(delim); }
527 
530  static void set_positions(Logger::LogPositions positions) { instance().set_positions(positions); }
531 
533  static void stop() { instance().stop(); }
534 
538  static bool is_loggable(Logger::Level lev) { return instance().is_loggable(lev); }
539 };
540 
541 //-----------------------------------------------------------------------------------------
542 class buffered_ostream : public std::ostream
543 {
544 protected:
545  class tsbuf : public std::streambuf
546  {
547  std::string _str;
548 
549  int_type overflow(int_type c)
550  {
551  if (c != traits_type::eof())
552  {
553  char z(c);
554  _str.append(&z, 1);
555  }
556  return c;
557  }
558 
559  std::streamsize xsputn(const char *s, std::streamsize num)
560  { _str.append(s, num); return num; }
561 
562  public:
563  tsbuf() = default;
564  ~tsbuf() = default;
565  const std::string& get() const { return _str; }
566  };
567 
569 
570 public:
571  buffered_ostream() : std::ostream(&_buf) {}
572  virtual ~buffered_ostream() {}
573 };
574 
575 //-----------------------------------------------------------------------------------------
576 using logger_function = std::function<bool(const std::string&, Logger::Level, const char *, const unsigned)>;
577 
579 {
582  const char *_loc;
583  const unsigned _value;
584 
585 public:
586  log_stream(decltype(_logger) func, Logger::Level lev=Logger::Info, const char *loc=nullptr, unsigned value=0)
587  : _logger(func), _lev(lev), _loc(loc), _value(value) {}
589 };
590 
591 //-----------------------------------------------------------------------------------------
594 
595 // our buffered RAII ostream singleton insertable log target, global ostream log target
596 
597 //-------------------------------------------------------------------------------------------------
598 
599 } // FIX8
600 
601 #define glout_info if (!FIX8::GlobalLogger::is_loggable(FIX8::Logger::Info)); \
602  else FIX8::log_stream(FIX8::logger_function(FIX8::GlobalLogger::enqueue), FIX8::Logger::Info, FILE_LINE)
603 #define glout glout_info
604 #define glout_warn if (!FIX8::GlobalLogger::is_loggable(FIX8::Logger::Warn)); \
605  else FIX8::log_stream(FIX8::logger_function(FIX8::GlobalLogger::enqueue), FIX8::Logger::Warn, FILE_LINE)
606 #define glout_error if (!FIX8::GlobalLogger::is_loggable(FIX8::Logger::Error)); \
607  else FIX8::log_stream(FIX8::logger_function(FIX8::GlobalLogger::enqueue), FIX8::Logger::Error, FILE_LINE)
608 #define glout_fatal if (!FIX8::GlobalLogger::is_loggable(FIX8::Logger::Fatal)); \
609  else FIX8::log_stream(FIX8::logger_function(FIX8::GlobalLogger::enqueue), FIX8::Logger::Fatal, FILE_LINE)
610 #if defined FIX8_DEBUG
611 #define glout_debug if (!FIX8::GlobalLogger::is_loggable(FIX8::Logger::Debug)); \
612  else FIX8::log_stream(FIX8::logger_function(FIX8::GlobalLogger::enqueue), FIX8::Logger::Debug, FILE_LINE)
613 #else
614 #define glout_debug true ? FIX8::null_insert() : FIX8::null_insert()
615 #endif
616 
617 #endif // FIX8_LOGGER_HPP_
Logger(const LogFlags flags, const Levels levels=Levels(All), const std::string delim=" ", const LogPositions positions=LogPositions())
Definition: logger.hpp:239
f8_thread< Logger > _thread
Definition: logger.hpp:155
f8_mutex _mutex
Definition: logger.hpp:179
virtual ~bcoutbuf()
Definition: logger.hpp:130
void stop()
Stop the logging thread.
Definition: logger.hpp:310
File descriptor output streambuf, inspiration from Josuttis N.M.
Definition: logger.hpp:50
A global singleton logger.
Definition: logger.hpp:475
unsigned _osequence
Definition: logger.hpp:220
static bool enqueue(const std::string &what, Logger::Level lev=Logger::Info, const char *fl=nullptr, unsigned int val=0)
Definition: logger.hpp:510
void set_flags(LogFlags flags)
Definition: logger.hpp:270
std::map< char, thread_id_t > RevThreadCodes
Definition: logger.hpp:225
virtual std::streamsize xsputn(const char *s, std::streamsize num)
Definition: logger.hpp:122
f8_thread_cancellation_token & cancellation_token()
Definition: logger.hpp:352
static const int rotation_default
Definition: logger.hpp:173
std::list< std::string > _buffer
Definition: logger.hpp:156
void set_positions(const std::vector< int > &positions)
Definition: logger.hpp:278
static void stop()
Definition: logger.hpp:533
virtual ~fptrostream()
Dtor.
Definition: logger.hpp:91
f8_thread delegated async logging class
Definition: logger.hpp:153
static const int StdFlags
Definition: logger.hpp:169
std::function< bool(const std::string &, Logger::Level, const char *, const unsigned)> logger_function
Definition: logger.hpp:576
bool send(const std::string &what, Level lev=Logger::Info, const char *fl=nullptr, const unsigned val=0)
Definition: logger.hpp:306
log_stream(decltype(_logger) func, Logger::Level lev=Logger::Info, const char *loc=nullptr, unsigned value=0)
Definition: logger.hpp:586
F8API XmlFileLogger(const std::string &pathname, const LogFlags flags, const Levels levels, const std::string delim=" ", const LogPositions positions=LogPositions(), const unsigned rotnum=rotation_default)
Definition: logger.hpp:396
static void flush_log()
Definition: logger.hpp:514
static void set_positions(Logger::LogPositions positions)
Definition: logger.hpp:530
generic pthread_mutex wrapper
Definition: thread.hpp:299
static const Tickval _started
The time the entire logging system was start.
Definition: logger.hpp:229
static const int All
Definition: logger.hpp:161
F8API char get_thread_code(thread_id_t tid)
Definition: logger.cpp:232
Socket output streambuf, inspiration from Josuttis N.M.
Definition: logger.hpp:107
void set_delimiter(const std::string &delim)
Definition: logger.hpp:274
LogElement(const LogElement &from)
Definition: logger.hpp:202
static FileLogger & instance()
Definition: logger.hpp:477
const char * _fileline
Definition: logger.hpp:193
std::ostream * _ofs
Definition: logger.hpp:184
RevThreadCodes _rev_thread_codes
Definition: logger.hpp:226
Poco::Net::DatagramSocket * _sock
Definition: logger.hpp:110
std::streamsize xsputn(const char *s, std::streamsize num)
Definition: logger.hpp:559
virtual ~XmlFileLogger()
Dtor.
Definition: logger.hpp:409
const size_t max_global_filename_length(1024)
int_type overflow(int_type c)
Definition: logger.hpp:549
void preamble()
Write the xml preamble. If you use rotate, you need to call this AFTER rotating.
Definition: logger.hpp:404
static bool is_loggable(Logger::Level lev)
Definition: logger.hpp:538
ebitset< Level > Levels
Definition: logger.hpp:175
static const std::vector< std::string > _bit_names
string representation of logflags
Definition: logger.hpp:326
bool has_flag(const Flags flg) const
Definition: logger.hpp:338
Thread wrapper. Ctor provides T instance and specifies ptr to member to call or defaults to operator(...
Definition: thread.hpp:245
virtual ~Logger()
Dtor.
Definition: logger.hpp:253
void postamble()
Write the xml postamble. If you use rotate, you need to call this BEFORE rotating.
Definition: logger.hpp:406
static const int None
Definition: logger.hpp:165
virtual int_type overflow(int_type c)
Definition: logger.hpp:55
Thread cancellation token.
Definition: thread.hpp:206
A file logger.
Definition: logger.hpp:385
static void set_delimiter(const std::string &delim)
Definition: logger.hpp:526
constexpr unsigned bitsum()
empty argument version
Definition: f8utils.hpp:826
virtual ~fdoutbuf()
Definition: logger.hpp:73
static void set_levels(Logger::Levels levels)
Definition: logger.hpp:522
std::vector< int > LogPositions
Definition: logger.hpp:176
virtual F8API void process_logline(LogElement *le)
Definition: logger.cpp:371
const std::string & get() const
Definition: logger.hpp:565
File pointer stream.
Definition: logger.hpp:77
virtual int join(int timeoutInMs=0)
Definition: thread.hpp:126
static const int max_rotation
Definition: logger.hpp:173
#define F8API
Definition: f8dll.h:60
static const std::vector< std::string > _level_names
string representation of levels
Definition: logger.hpp:329
virtual int_type overflow(int_type c)
Definition: logger.hpp:112
const Logger::Level _lev
Definition: logger.hpp:581
virtual F8API bool rotate(bool force=false)
Definition: logger.cpp:267
F8API void purge_thread_codes()
Remove dead threads from the thread code cache.
Definition: logger.cpp:206
unsigned _sequence
Definition: logger.hpp:220
A broadcast logger.
Definition: logger.hpp:436
bcoutbuf(Poco::Net::DatagramSocket *sock)
Definition: logger.hpp:129
virtual ~bcostream()
Dtor.
Definition: logger.hpp:145
const unsigned _value
Definition: logger.hpp:583
generic spin_lock wrapper
Definition: thread.hpp:364
tbb::concurrent_bounded_queue< T > f8_concurrent_queue
Definition: mpmc.hpp:48
static const Tickval & get_time_started()
Definition: logger.hpp:333
PipeLogger(const std::string &command, const LogFlags flags, const Levels levels, const std::string delim=" ", LogPositions positions=LogPositions())
Definition: logger.cpp:315
bool enqueue(const std::string &what, Level lev=Logger::Info, const char *fl=nullptr, const unsigned val=0)
Definition: logger.hpp:294
virtual std::ostream & get_stream() const
Definition: logger.hpp:286
std::map< thread_id_t, char > ThreadCodes
Definition: logger.hpp:222
A file logger.
Definition: logger.hpp:357
char * CopyString(const std::string &src, char *target, unsigned limit=0)
Definition: f8utils.hpp:1100
virtual F8API void process_logline(LogElement *le)
Definition: logger.cpp:110
bcoutbuf buf_
Definition: logger.hpp:137
bcostream(Poco::Net::DatagramSocket *sock)
Definition: logger.hpp:142
LogPositions _positions
Definition: logger.hpp:231
LogElement(const thread_id_t tid, const std::string &str, Level level, const char *fl=nullptr, const unsigned val=0)
Definition: logger.hpp:197
virtual std::streamsize xsputn(const char *s, std::streamsize num)
Definition: logger.hpp:66
static void set_global_filename(const std::string &from)
Definition: logger.hpp:492
fdoutbuf buf_
Definition: logger.hpp:82
virtual ~FileLogger()
Dtor.
Definition: logger.hpp:375
integral_type has(const T sbit) const
Definition: f8utils.hpp:876
F8API char glob_log0[max_global_filename_length]
Definition: logger.cpp:46
virtual ~buffered_ostream()
Definition: logger.hpp:572
const char * _loc
Definition: logger.hpp:582
A pipe logger.
Definition: logger.hpp:418
ThreadCodes _thread_codes
Definition: logger.hpp:223
f8_concurrent_queue< LogElement > _msg_queue
Definition: logger.hpp:219
std::thread::id thread_id_t
Definition: thread.hpp:58
unsigned _rotnum
Definition: logger.hpp:361
bool is_loggable(Level level) const
Definition: logger.hpp:262
BCLogger(Poco::Net::DatagramSocket *sock, const LogFlags flags, const Levels levels, const std::string delim=" ", LogPositions positions=LogPositions())
Definition: logger.cpp:341
LogElement & operator=(const LogElement &that)
Definition: logger.hpp:204
virtual F8API void flush()
Flush the buffer.
Definition: logger.cpp:196
Levels _levels
Definition: logger.hpp:182
fdoutbuf(int _fd)
Definition: logger.hpp:72
LogElement(const thread_id_t tid, const std::string &str, const unsigned val=0)
Definition: logger.hpp:199
f8_spin_lock _log_spl
Definition: logger.hpp:180
udp stream
Definition: logger.hpp:134
std::string _delim
Definition: logger.hpp:183
static const int Errors
Definition: logger.hpp:161
virtual ~PipeLogger()
Dtor.
Definition: logger.hpp:431
static bool log(const std::string &what, Logger::Level lev=Logger::Info, const char *fl=nullptr, unsigned int val=0)
Definition: logger.hpp:501
f8_thread_cancellation_token _stopping
Definition: logger.hpp:186
virtual bool rotate(bool force=false)
Definition: logger.hpp:315
LogFlags _flags
Definition: logger.hpp:181
logger_function _logger
Definition: logger.hpp:580
F8API int operator()()
Definition: logger.cpp:60
std::string _pathname
Definition: logger.hpp:360
virtual ~BCLogger()
Dtor.
Definition: logger.hpp:465
void set_levels(Levels levels)
Definition: logger.hpp:266
F8API FileLogger(const std::string &pathname, const LogFlags flags, const Levels levels, const std::string delim=" ", const LogPositions positions=LogPositions(), const unsigned rotnum=rotation_default)
Definition: logger.cpp:255
fptrostream(FILE *fptr)
Definition: logger.hpp:87
void request_stop()
Tell the thread to stop.
Definition: thread.hpp:219
static void set_flags(Logger::LogFlags flags)
Definition: logger.hpp:518
size_t _lines
Definition: logger.hpp:185