All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
flashmatch::logger Class Reference

Utility class used to show formatted message on the screen. A logger class for flashmatch. Simply shows a formatted colored message on a screen.
A static getter method is provided to create a sharable logger instance (see OpT0FinderBase for useage).
. More...

#include <OpT0FinderLogger.h>

Public Member Functions

 logger (const std::string &name="no_name")
 Default constructor. More...
 
virtual ~logger ()
 Default destructor. More...
 
const std::string & name () const
 Logger's name. More...
 
void set (const msg::Level_t level)
 Verbosity level setter. More...
 
msg::Level_t level () const
 Verbosity level getter. More...
 
bool operator< (const logger &rhs) const
 Comparison operator for static collection of loggers. More...
 
bool debug () const
 
bool info () const
 
bool normal () const
 
bool warning () const
 
bool error () const
 
std::ostream & send (const msg::Level_t) const
 Formatted message (simplest) More...
 
std::ostream & send (const msg::Level_t level, const std::string &function) const
 Formatted message (function name included) More...
 
std::ostream & send (const msg::Level_t level, const std::string &function, const unsigned int line_num) const
 Formatted message (function name + line number) More...
 
std::ostream & send (const msg::Level_t level, const std::string &function, const unsigned int line_num, const std::string &file_name) const
 Formatted message (function name + line number + file name) More...
 

Static Public Member Functions

static loggerget (const std::string name)
 Getter of a message instance. More...
 
static msg::Level_t default_level ()
 Default logger level getter. More...
 
static void default_level (msg::Level_t l)
 Default logger level setter (only affect future loggers) More...
 
static void force_level (msg::Level_t l)
 Force all loggers to change level. More...
 

Private Attributes

std::ostream * _ostrm
 ostream More...
 
msg::Level_t _level
 Level. More...
 
std::string _name
 Name. More...
 

Static Private Attributes

static std::map< std::string,
flashmatch::logger > * 
_logger_m = nullptr
 Set of loggers. More...
 
static msg::Level_t _level_default = msg::kNORMAL
 Default logger level. More...
 

Detailed Description

Utility class used to show formatted message on the screen. A logger class for flashmatch. Simply shows a formatted colored message on a screen.
A static getter method is provided to create a sharable logger instance (see OpT0FinderBase for useage).
.

Definition at line 30 of file OpT0FinderLogger.h.

Constructor & Destructor Documentation

flashmatch::logger::logger ( const std::string &  name = "no_name")
inline

Default constructor.

Definition at line 35 of file OpT0FinderLogger.h.

36  : _ostrm(&std::cout)
37  , _name(name)
38  {}
std::string _name
Name.
std::ostream * _ostrm
ostream
const std::string & name() const
Logger&#39;s name.
BEGIN_PROLOG could also be cout
virtual flashmatch::logger::~logger ( )
inlinevirtual

Default destructor.

Definition at line 41 of file OpT0FinderLogger.h.

41 {};

Member Function Documentation

bool flashmatch::logger::debug ( ) const
inline

Definition at line 105 of file OpT0FinderLogger.h.

105 { return _level <= msg::kDEBUG; }
msg::Level_t _level
Level.
static msg::Level_t flashmatch::logger::default_level ( )
inlinestatic

Default logger level getter.

Definition at line 92 of file OpT0FinderLogger.h.

92 { return _level_default; }
static msg::Level_t _level_default
Default logger level.
static void flashmatch::logger::default_level ( msg::Level_t  l)
inlinestatic

Default logger level setter (only affect future loggers)

Definition at line 94 of file OpT0FinderLogger.h.

94 { _level_default = l; }
static msg::Level_t _level_default
Default logger level.
bool flashmatch::logger::error ( ) const
inline

Definition at line 109 of file OpT0FinderLogger.h.

109 { return _level <= msg::kERROR; }
msg::Level_t _level
Level.
static void flashmatch::logger::force_level ( msg::Level_t  l)
inlinestatic

Force all loggers to change level.

Definition at line 96 of file OpT0FinderLogger.h.

97  {
98  default_level(l);
99  for(auto& name_logger : *_logger_m) name_logger.second.set(l);
100  }
static msg::Level_t default_level()
Default logger level getter.
static std::map< std::string, flashmatch::logger > * _logger_m
Set of loggers.
static logger& flashmatch::logger::get ( const std::string  name)
inlinestatic

Getter of a message instance.

Definition at line 80 of file OpT0FinderLogger.h.

81  {
82  if(!_logger_m) _logger_m = new std::map<std::string,flashmatch::logger>();
83  auto iter = _logger_m->find(name);
84  if(iter == _logger_m->end()) {
85  iter = _logger_m->emplace(name,logger(name)).first;
86  iter->second.set(msg::kNORMAL);
87  }
88  return iter->second;
89  };
logger(const std::string &name="no_name")
Default constructor.
const std::string & name() const
Logger&#39;s name.
static std::map< std::string, flashmatch::logger > * _logger_m
Set of loggers.
bool flashmatch::logger::info ( ) const
inline

Definition at line 106 of file OpT0FinderLogger.h.

106 { return _level <= msg::kINFO; }
msg::Level_t _level
Level.
msg::Level_t flashmatch::logger::level ( ) const
inline

Verbosity level getter.

Definition at line 69 of file OpT0FinderLogger.h.

69 { return _level; }
msg::Level_t _level
Level.
const std::string& flashmatch::logger::name ( ) const
inline

Logger's name.

Definition at line 63 of file OpT0FinderLogger.h.

63 { return _name; }
std::string _name
Name.
bool flashmatch::logger::normal ( ) const
inline

Definition at line 107 of file OpT0FinderLogger.h.

107 { return _level <= msg::kNORMAL; }
msg::Level_t _level
Level.
bool flashmatch::logger::operator< ( const logger rhs) const
inline

Comparison operator for static collection of loggers.

Definition at line 72 of file OpT0FinderLogger.h.

73  {
74  if(_name < rhs.name()) return true;
75  if(_name > rhs.name()) return false;
76  return false;
77  }
std::string _name
Name.
std::ostream & flashmatch::logger::send ( const msg::Level_t  level) const

Formatted message (simplest)

Definition at line 11 of file OpT0FinderLogger.cxx.

12  {
13  (*_ostrm) << msg::kStringPrefix[level].c_str()
14  << "\033[0m ";
15  return (*_ostrm);
16  }
msg::Level_t level() const
Verbosity level getter.
std::ostream * _ostrm
ostream
const std::string kStringPrefix[kMSG_TYPE_MAX]
Prefix of message.
std::ostream & flashmatch::logger::send ( const msg::Level_t  level,
const std::string &  function 
) const

Formatted message (function name included)

Definition at line 18 of file OpT0FinderLogger.cxx.

20  {
21  auto& strm(send(level));
22  strm << "\033[94m<" << _name << "::" << function.c_str() << ">\033[00m ";
23  return strm;
24  }
std::string _name
Name.
msg::Level_t level() const
Verbosity level getter.
std::ostream & send(const msg::Level_t) const
Formatted message (simplest)
std::ostream & flashmatch::logger::send ( const msg::Level_t  level,
const std::string &  function,
const unsigned int  line_num 
) const

Formatted message (function name + line number)

Definition at line 26 of file OpT0FinderLogger.cxx.

29  {
30  auto& strm(send(level));
31  strm << "\033[94m<" << _name << "::" << function.c_str() << "::L" << line_num << ">\033[00m ";
32  return strm;
33  }
std::string _name
Name.
msg::Level_t level() const
Verbosity level getter.
std::ostream & send(const msg::Level_t) const
Formatted message (simplest)
std::ostream & flashmatch::logger::send ( const msg::Level_t  level,
const std::string &  function,
const unsigned int  line_num,
const std::string &  file_name 
) const

Formatted message (function name + line number + file name)

Definition at line 35 of file OpT0FinderLogger.cxx.

39  {
40  auto& strm(send(level,function));
41  // FIXME temporary operation to fetch file name from full path
42  strm << file_name.substr(file_name.rfind("/")+1,file_name.size()).c_str() << "::L" << line_num << " ";
43  return strm;
44  }
msg::Level_t level() const
Verbosity level getter.
std::ostream & send(const msg::Level_t) const
Formatted message (simplest)
then echo fcl sbnd_project sbnd_project sbnd_project sbnd_project production production file_name
void flashmatch::logger::set ( const msg::Level_t  level)
inline

Verbosity level setter.

Definition at line 66 of file OpT0FinderLogger.h.

66 { _level = level; }
msg::Level_t level() const
Verbosity level getter.
msg::Level_t _level
Level.
bool flashmatch::logger::warning ( ) const
inline

Definition at line 108 of file OpT0FinderLogger.h.

108 { return _level <= msg::kWARNING; }
msg::Level_t _level
Level.

Member Data Documentation

msg::Level_t flashmatch::logger::_level
private

Level.

Definition at line 49 of file OpT0FinderLogger.h.

msg::Level_t flashmatch::logger::_level_default = msg::kNORMAL
staticprivate

Default logger level.

Definition at line 58 of file OpT0FinderLogger.h.

std::map< std::string, logger > * flashmatch::logger::_logger_m = nullptr
staticprivate

Set of loggers.

Definition at line 55 of file OpT0FinderLogger.h.

std::string flashmatch::logger::_name
private

Name.

Definition at line 52 of file OpT0FinderLogger.h.

std::ostream* flashmatch::logger::_ostrm
private

ostream

Definition at line 41 of file OpT0FinderLogger.h.


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