fix8  version 1.4.0
Open Source C++ FIX Framework
FIX8::PipeLogger Class Reference

A pipe logger. More...

#include <logger.hpp>

Inheritance diagram for FIX8::PipeLogger:
FIX8::Logger

Public Member Functions

 PipeLogger (const std::string &command, const LogFlags flags, const Levels levels, const std::string delim=" ", LogPositions positions=LogPositions())
 
virtual ~PipeLogger ()
 Dtor. More...
 
- Public Member Functions inherited from FIX8::Logger
 Logger (const LogFlags flags, const Levels levels=Levels(All), const std::string delim=" ", const LogPositions positions=LogPositions())
 
virtual ~Logger ()
 Dtor. More...
 
bool is_loggable (Level level) const
 
void set_levels (Levels levels)
 
void set_flags (LogFlags flags)
 
void set_delimiter (const std::string &delim)
 
void set_positions (const std::vector< int > &positions)
 
virtual std::ostream & get_stream () const
 
bool enqueue (const std::string &what, Level lev=Logger::Info, const char *fl=nullptr, const unsigned val=0)
 
bool send (const std::string &what, Level lev=Logger::Info, const char *fl=nullptr, const unsigned val=0)
 
void stop ()
 Stop the logging thread. More...
 
virtual bool rotate (bool force=false)
 
F8API int operator() ()
 
virtual F8API void process_logline (LogElement *le)
 
bool has_flag (const Flags flg) const
 
F8API char get_thread_code (thread_id_t tid)
 
F8API void purge_thread_codes ()
 Remove dead threads from the thread code cache. More...
 
virtual F8API void flush ()
 Flush the buffer. More...
 
f8_thread_cancellation_tokencancellation_token ()
 

Additional Inherited Members

- Public Types inherited from FIX8::Logger
enum  Level {
  Debug, Info, Warn, Error,
  Fatal
}
 
enum  Flags {
  mstart, sstart, sequence, thread,
  timestamp, minitimestamp, direction, level,
  location, start_controls, append =start_controls, buffer,
  compress, pipe, broadcast, nolf,
  inbound, outbound, xml, num_flags
}
 
using LogFlags = ebitset< Flags >
 
using Levels = ebitset< Level >
 
using LogPositions = std::vector< int >
 
- Static Public Member Functions inherited from FIX8::Logger
static const Tickvalget_time_started ()
 
- Static Public Attributes inherited from FIX8::Logger
static const int Errors = bitsum(Warn,Error,Fatal)
 
static const int All = bitsum(Debug,Info,Warn,Error,Fatal)
 
static const int None = 0
 
static const int StdFlags = bitsum(sequence,thread,timestamp,level)
 
static const int rotation_default = 5
 
static const int max_rotation = 1024
 
static const std::vector< std::string > _bit_names
 string representation of logflags More...
 
static const std::vector< std::string > _level_names { "Debug", "Info ", "Warn ", "Error", "Fatal" }
 string representation of levels More...
 
- Protected Types inherited from FIX8::Logger
using ThreadCodes = std::map< thread_id_t, char >
 
using RevThreadCodes = std::map< char, thread_id_t >
 
- Protected Attributes inherited from FIX8::Logger
f8_mutex _mutex
 
f8_spin_lock _log_spl
 
LogFlags _flags
 
Levels _levels
 
std::string _delim
 
std::ostream * _ofs = nullptr
 
size_t _lines = 0
 
f8_thread_cancellation_token _stopping
 
f8_concurrent_queue< LogElement_msg_queue
 
unsigned _sequence = 0
 
unsigned _osequence = 0
 
ThreadCodes _thread_codes
 
RevThreadCodes _rev_thread_codes
 
LogPositions _positions
 
- Static Protected Attributes inherited from FIX8::Logger
static const Tickval _started { true }
 The time the entire logging system was start. More...
 

Detailed Description

A pipe logger.

Definition at line 418 of file logger.hpp.

Constructor & Destructor Documentation

PipeLogger::PipeLogger ( const std::string &  command,
const LogFlags  flags,
const Levels  levels,
const std::string  delim = " ",
LogPositions  positions = LogPositions() 
)

Ctor.

Parameters
commandpipe command
flagsebitset flags
levelsebitset levels
delimfield delimiter
positionsfield positions

Definition at line 315 of file logger.cpp.

References FIX8::Logger::_flags, FIX8::Logger::_ofs, glout_info, and FIX8::Logger::pipe.

317  : Logger(flags, levels, delim, positions)
318 {
319  const string pathname(fname.substr(1));
320 
321  if (fname[0] != '|')
322  throw f8Exception("pipe command must be prefixed with '|'");
323 
324 #ifdef _MSC_VER
325  FILE *pcmd(_popen(pathname.c_str(), "w"));
326 #else
327  FILE *pcmd(popen(pathname.c_str(), "w"));
328 #endif
329 
330  if (pcmd == 0)
331  glout_info << "PipeLogger: " << pathname << ": failed to execute";
332  else
333  {
334  _ofs = new fptrostream(pcmd);
335  _flags |= pipe;
336  }
337 }
Logger(const LogFlags flags, const Levels levels=Levels(All), const std::string delim=" ", const LogPositions positions=LogPositions())
Definition: logger.hpp:239
std::ostream * _ofs
Definition: logger.hpp:184
File pointer stream.
Definition: logger.hpp:77
Base exception class.
Definition: f8exception.hpp:49
#define glout_info
Definition: logger.hpp:601
LogFlags _flags
Definition: logger.hpp:181
virtual FIX8::PipeLogger::~PipeLogger ( )
inlinevirtual

Dtor.

Definition at line 431 of file logger.hpp.

431 {}

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