fix8  version 1.4.0
Open Source C++ FIX Framework
FIX8::SingleLogger< fn > Class Template Reference

A global singleton logger. More...

#include <logger.hpp>

Static Public Member Functions

static void set_global_filename (const std::string &from)
 
static bool log (const std::string &what, Logger::Level lev=Logger::Info, const char *fl=nullptr, unsigned int val=0)
 
static bool enqueue (const std::string &what, Logger::Level lev=Logger::Info, const char *fl=nullptr, unsigned int val=0)
 
static void flush_log ()
 
static void set_flags (Logger::LogFlags flags)
 
static void set_levels (Logger::Levels levels)
 
static void set_delimiter (const std::string &delim)
 
static void set_positions (Logger::LogPositions positions)
 
static void stop ()
 
static bool is_loggable (Logger::Level lev)
 

Static Private Member Functions

static FileLoggerinstance ()
 

Detailed Description

template<char * fn>
class FIX8::SingleLogger< fn >

A global singleton logger.

Template Parameters
fnactual pathname of logfile

Create a static instance of this template and set the template parameter to the desired logfile pathname

Definition at line 475 of file logger.hpp.

Member Function Documentation

template<char * fn>
static bool FIX8::SingleLogger< fn >::enqueue ( const std::string &  what,
Logger::Level  lev = Logger::Info,
const char *  fl = nullptr,
unsigned int  val = 0 
)
inlinestatic

Enqueue a message to the logger. Will not check log level.

Parameters
whatmessage to log
levlevel to log
flpointer to fileline
valextra value to log
Returns
true on success

Definition at line 510 of file logger.hpp.

References FIX8::Logger::enqueue(), and FIX8::SingleLogger< fn >::instance().

511  { return instance().enqueue(what, lev, fl, val); }
static FileLogger & instance()
Definition: logger.hpp:477
bool enqueue(const std::string &what, Level lev=Logger::Info, const char *fl=nullptr, const unsigned val=0)
Definition: logger.hpp:294
template<char * fn>
static void FIX8::SingleLogger< fn >::flush_log ( )
inlinestatic

Flush the logger

Definition at line 514 of file logger.hpp.

References FIX8::Logger::flush(), and FIX8::SingleLogger< fn >::instance().

514 { instance().flush(); }
static FileLogger & instance()
Definition: logger.hpp:477
virtual F8API void flush()
Flush the buffer.
Definition: logger.cpp:196
template<char * fn>
static bool FIX8::SingleLogger< fn >::is_loggable ( Logger::Level  lev)
inlinestatic

Check if the given log level is set for this logger

Parameters
levlevel to test
Returns
true if available

Definition at line 538 of file logger.hpp.

References FIX8::SingleLogger< fn >::instance(), and FIX8::Logger::is_loggable().

538 { return instance().is_loggable(lev); }
static FileLogger & instance()
Definition: logger.hpp:477
bool is_loggable(Level level) const
Definition: logger.hpp:262
template<char * fn>
static bool FIX8::SingleLogger< fn >::log ( const std::string &  what,
Logger::Level  lev = Logger::Info,
const char *  fl = nullptr,
unsigned int  val = 0 
)
inlinestatic

Send a message to the logger.

Parameters
whatmessage to log
levlevel to log
flpointer to fileline
valextra value to log
Returns
true on success

Definition at line 501 of file logger.hpp.

References FIX8::SingleLogger< fn >::instance(), and FIX8::Logger::send().

Referenced by main().

502  { return instance().send(what, lev, fl, val); }
bool send(const std::string &what, Level lev=Logger::Info, const char *fl=nullptr, const unsigned val=0)
Definition: logger.hpp:306
static FileLogger & instance()
Definition: logger.hpp:477
template<char * fn>
static void FIX8::SingleLogger< fn >::set_delimiter ( const std::string &  delim)
inlinestatic

Set the field delimiter

Parameters
delimdelimiter value to set

Definition at line 526 of file logger.hpp.

References FIX8::SingleLogger< fn >::instance(), and FIX8::Logger::set_delimiter().

526 { instance().set_delimiter(delim); }
void set_delimiter(const std::string &delim)
Definition: logger.hpp:274
static FileLogger & instance()
Definition: logger.hpp:477
template<char * fn>
static void FIX8::SingleLogger< fn >::set_flags ( Logger::LogFlags  flags)
inlinestatic

Set the logflags

Parameters
flagsflags to set

Definition at line 518 of file logger.hpp.

References FIX8::SingleLogger< fn >::instance(), and FIX8::Logger::set_flags().

518 { instance().set_flags(flags); }
void set_flags(LogFlags flags)
Definition: logger.hpp:270
static FileLogger & instance()
Definition: logger.hpp:477
template<char * fn>
static void FIX8::SingleLogger< fn >::set_global_filename ( const std::string &  from)
inlinestatic

Set the global logfile name.

Parameters
fromname to set to

Definition at line 492 of file logger.hpp.

References FIX8::CopyString(), and FIX8::max_global_filename_length().

Referenced by main().

493  { CopyString(from, fn, max_global_filename_length); }
const size_t max_global_filename_length(1024)
char * CopyString(const std::string &src, char *target, unsigned limit=0)
Definition: f8utils.hpp:1100
template<char * fn>
static void FIX8::SingleLogger< fn >::set_levels ( Logger::Levels  levels)
inlinestatic

Set the log levels

Parameters
levelslevels to set

Definition at line 522 of file logger.hpp.

References FIX8::SingleLogger< fn >::instance(), and FIX8::Logger::set_levels().

522 { instance().set_levels(levels); }
static FileLogger & instance()
Definition: logger.hpp:477
void set_levels(Levels levels)
Definition: logger.hpp:266
template<char * fn>
static void FIX8::SingleLogger< fn >::set_positions ( Logger::LogPositions  positions)
inlinestatic

Set the log positions

Parameters
positionspositions to set

Definition at line 530 of file logger.hpp.

References FIX8::SingleLogger< fn >::instance(), and FIX8::Logger::set_positions().

530 { instance().set_positions(positions); }
void set_positions(const std::vector< int > &positions)
Definition: logger.hpp:278
static FileLogger & instance()
Definition: logger.hpp:477
template<char * fn>
static void FIX8::SingleLogger< fn >::stop ( )
inlinestatic

Stop the logger

Definition at line 533 of file logger.hpp.

References FIX8::SingleLogger< fn >::instance(), and FIX8::Logger::stop().

533 { instance().stop(); }
void stop()
Stop the logging thread.
Definition: logger.hpp:310
static FileLogger & instance()
Definition: logger.hpp:477

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