gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-252-gf9a3f78
a Global And Modular Bsm Inference Tool
Gambit::Logging Namespace Reference

Forward declare minimial logging components needed to use logger. More...

Classes

class  BaseLogger
 Logger virtual base class. More...
 
struct  endofmessage
 Special (empty) struct for signalling end of message to LogMaster stream. More...
 
class  LogMaster
 Logging "controller" object Keeps track of the various "Logger" objects. More...
 
struct  Message
 structure for storing log messages and metadata More...
 
struct  SortedMessage
 structure for storing log messages and metadata after tags are sorted More...
 
class  StdLogger
 Logger for 'standard' messages. More...
 

Typedefs

typedef std::ostream &(* manip1) (std::ostream &)
 
typedef std::basic_ios< std::ostream::char_type, std::ostream::traits_type > ios_type
 
typedef ios_type &(* manip2) (ios_type &)
 
typedef std::ios_base &(* manip3) (std::ios_base &)
 

Functions

int str2tag (const std::string &)
 
std::map< int, std::string > & tag2str ()
 
std::set< int > & components ()
 
const std::set< LogTag > & msgtypes ()
 
const std::set< LogTag > & flags ()
 
const std::set< LogTag > & echoes ()
 
int getfreetag ()
 
void checktags ()
 Function to inspect tags and their associated strings. For testing purposes only. More...
 
LogMasteroperator<< (LogMaster &, const std::string &)
 Stream functions for use with LogMaster. More...
 
LogMasteroperator<< (LogMaster &logobj, const LogTag &tag)
 Handle LogTag input. More...
 
LogMasteroperator<< (LogMaster &logobj, const endofmessage &eom)
 Handle end of message character. More...
 
LogMasteroperator<< (LogMaster &logobj, const manip1 fp)
 Handle various stream manipulators. More...
 
LogMasteroperator<< (LogMaster &, const manip2)
 
LogMasteroperator<< (LogMaster &, const manip3)
 
template<typename TYPE >
LogMasteroperator<< (LogMaster &logobj, const TYPE &input)
 
template<typename TYPE >
LogMasteroperator<< (LogMaster &logobj, TYPE &input)
 

Variables

const bool verbose = false
 

Detailed Description

Forward declare minimial logging components needed to use logger.

Typedef Documentation

◆ ios_type

typedef std::basic_ios< std::ostream::char_type, std::ostream::traits_type > Gambit::Logging::ios_type

Definition at line 57 of file logger.hpp.

◆ manip1

typedef std::ostream&(* Gambit::Logging::manip1) (std::ostream &)

Definition at line 56 of file logger.hpp.

◆ manip2

typedef ios_type&(* Gambit::Logging::manip2) (ios_type &)

Definition at line 58 of file logger.hpp.

◆ manip3

typedef std::ios_base&(* Gambit::Logging::manip3) (std::ios_base &)

Definition at line 59 of file logger.hpp.

Function Documentation

◆ checktags()

void Gambit::Logging::checktags ( )

Function to inspect tags and their associated strings. For testing purposes only.

Definition at line 163 of file logging.cpp.

References components(), echoes(), flags(), msgtypes(), and tag2str().

164  {
165  std::cout<<"Checking message type LogTags..."<<std::endl;
166  for(std::set<LogTag>::iterator tag = msgtypes().begin(); tag != msgtypes().end(); ++tag)
167  {
168  std::cout<<" "<<*tag<<" : "<<tag2str()[*tag]<<std::endl;
169  }
170  std::cout<<"Checking message flag LogTags..."<<std::endl;
171  for(std::set<LogTag>::iterator tag = flags().begin(); tag != flags().end(); ++tag)
172  {
173  std::cout<<" "<<*tag<<" : "<<tag2str()[*tag]<<std::endl;
174  }
175  std::cout<<"Checking message echo LogTags..."<<std::endl;
176  for(std::set<LogTag>::iterator tag = echoes().begin(); tag != echoes().end(); ++tag)
177  {
178  std::cout<<" "<<*tag<<" : "<<tag2str()[*tag]<<std::endl;
179  }
180  std::cout<<"Checking Gambit component LogTags..."<<std::endl;
181  for(std::set<int>::iterator tag = components().begin(); tag != components().end(); ++tag)
182  {
183  std::cout<<" "<<*tag<<" : "<<tag2str()[*tag]<<std::endl;
184  }
185  std::cout<<"LogTag check finished."<<std::endl;
186  }
std::map< int, std::string > & tag2str()
Definition: logging.cpp:130
const std::set< LogTag > & echoes()
Definition: logging.cpp:73
std::set< int > & components()
Definition: logging.cpp:81
const std::set< LogTag > & flags()
Definition: logging.cpp:65
const std::set< LogTag > & msgtypes()
Definition: logging.cpp:57
Here is the call graph for this function:

◆ components()

std::set< int > & Gambit::Logging::components ( )

Definition at line 81 of file logging.cpp.

References Gambit::LogTags::backends, Gambit::LogTags::core, Gambit::LogTags::debug, Gambit::LogTags::def, Gambit::LogTags::dependency_resolver, Gambit::LogTags::err, Gambit::LogTags::fatal, Gambit::LogTags::info, Gambit::LogTags::inifile, Gambit::LogTags::logs, Gambit::LogTags::models, Gambit::LogTags::nonfatal, Gambit::LogTags::printers, Gambit::LogTags::repeat_to_cerr, Gambit::LogTags::repeat_to_cout, Gambit::LogTags::scanner, Gambit::LogTags::utils, and Gambit::LogTags::warn.

Referenced by checktags(), Gambit::register_module_with_log(), and Gambit::Logging::SortedMessage::SortedMessage().

82  {
83  // We add the core components here, but the module and backend numbers are added later, so the set cannot be const.
85  static std::set<int> components_set(core_a, core_a+sizeof(core_a)/sizeof(core_a[0]));
86  return components_set;
87  }
LogTags::LogTag_declaration LogTag
Definition: log_tags.hpp:62
Here is the caller graph for this function:

◆ echoes()

const std::set< LogTag > & Gambit::Logging::echoes ( )

Definition at line 73 of file logging.cpp.

References Gambit::LogTags::repeat_to_cerr, and Gambit::LogTags::repeat_to_cout.

Referenced by checktags(), and Gambit::Logging::SortedMessage::SortedMessage().

74  {
75  static LogTag echoes_a[] = {repeat_to_cout, repeat_to_cerr};
76  static const std::set<LogTag> echoes_set(echoes_a, echoes_a+sizeof(echoes_a)/sizeof(echoes_a[0]));
77  return echoes_set;
78  }
LogTags::LogTag_declaration LogTag
Definition: log_tags.hpp:62
Here is the caller graph for this function:

◆ flags()

const std::set< LogTag > & Gambit::Logging::flags ( )

Definition at line 65 of file logging.cpp.

References Gambit::LogTags::fatal, and Gambit::LogTags::nonfatal.

Referenced by checktags(), Gambit::Scanner::Plugins::Plugin_Loader::Plugin_Loader(), and Gambit::Logging::SortedMessage::SortedMessage().

66  {
67  static LogTag flags_a[] = {fatal, nonfatal};
68  static const std::set<LogTag> flags_set(flags_a, flags_a+sizeof(flags_a)/sizeof(flags_a[0]));
69  return flags_set;
70  }
LogTags::LogTag_declaration LogTag
Definition: log_tags.hpp:62
Here is the caller graph for this function:

◆ getfreetag()

int Gambit::Logging::getfreetag ( )

Definition at line 138 of file logging.cpp.

References tag2str().

Referenced by Gambit::register_module_with_log().

139  {
140  for(int i=0; i<std::numeric_limits<int>::max(); ++i)
141  {
142  if( tag2str().count(i) == 0 ) { return i; }
143  }
144  // Uh oh, seems like we ran out of integers. If this happens you are screwed, and we have to rewrite the code to use long ints instead, or you have to unhook some modules.
145  // Cannot log this because we are outside the LogMaster class code.
146  std::ostringstream ss;
147  ss << "Error in logger.cpp! It seems that you have so many logging tags that you have exceeded the maximum allowed integer. There is no way you can fix this except to have fewer modules hooked up to gambit all at once. Otherwise we have to rewrite the logger to work with long ints or some such" << std::endl;
148  throw std::overflow_error( ss.str() );
149  }
std::map< int, std::string > & tag2str()
Definition: logging.cpp:130
Here is the call graph for this function:
Here is the caller graph for this function:

◆ msgtypes()

const std::set< LogTag > & Gambit::Logging::msgtypes ( )

Definition at line 57 of file logging.cpp.

References Gambit::LogTags::debug, Gambit::LogTags::err, Gambit::LogTags::info, and Gambit::LogTags::warn.

Referenced by checktags(), and Gambit::Logging::SortedMessage::SortedMessage().

58  {
59  static LogTag msg_a[] = {debug, info, warn, err};
60  static const std::set<LogTag> msgtypes_set(msg_a, msg_a+sizeof(msg_a)/sizeof(msg_a[0]));
61  return msgtypes_set;
62  }
LogTags::LogTag_declaration LogTag
Definition: log_tags.hpp:62
Here is the caller graph for this function:

◆ operator<<() [1/8]

LogMaster & Gambit::Logging::operator<< ( LogMaster logobj,
const std::string &  in 
)

Stream functions for use with LogMaster.

{@ Stream functions overloads for working with the logger

Stream functions for use with LogMaster

Definition at line 52 of file logger.cpp.

References Gambit::Logging::LogMaster::input().

53  {
54  logobj.input(in);
55  return logobj;
56  }
Here is the call graph for this function:

◆ operator<<() [2/8]

LogMaster & Gambit::Logging::operator<< ( LogMaster logobj,
const LogTag tag 
)

Handle LogTag input.

Definition at line 59 of file logger.cpp.

References Gambit::Logging::LogMaster::input().

60  {
61  logobj.input(tag);
62  return logobj;
63  }
Here is the call graph for this function:

◆ operator<<() [3/8]

LogMaster & Gambit::Logging::operator<< ( LogMaster logobj,
const endofmessage eom 
)

Handle end of message character.

Definition at line 66 of file logger.cpp.

References Gambit::Logging::LogMaster::input().

67  {
68  logobj.input(eom);
69  return logobj;
70  }
Here is the call graph for this function:

◆ operator<<() [4/8]

LogMaster & Gambit::Logging::operator<< ( LogMaster logobj,
const manip1  fp 
)

Handle various stream manipulators.

Definition at line 73 of file logger.cpp.

References Gambit::Logging::LogMaster::input().

74  {
75  logobj.input(fp);
76  return logobj;
77  }
Here is the call graph for this function:

◆ operator<<() [5/8]

LogMaster & Gambit::Logging::operator<< ( LogMaster logobj,
const manip2  fp 
)

Definition at line 79 of file logger.cpp.

References Gambit::Logging::LogMaster::input().

80  {
81  logobj.input(fp);
82  return logobj;
83  }
Here is the call graph for this function:

◆ operator<<() [6/8]

LogMaster & Gambit::Logging::operator<< ( LogMaster logobj,
const manip3  fp 
)

Definition at line 85 of file logger.cpp.

References Gambit::Logging::LogMaster::input().

86  {
87  logobj.input(fp);
88  return logobj;
89  }
Here is the call graph for this function:

◆ operator<<() [7/8]

template<typename TYPE >
LogMaster& Gambit::Logging::operator<< ( LogMaster logobj,
const TYPE &  input 
)

Definition at line 77 of file logger.hpp.

78  {
79  using ::Gambit::operator<<; // Unhide operator overloads in Gambit scope
80  std::stringstream ss;
81  ss << input;
82  logobj << ss.str();
83  return logobj;
84  }

◆ operator<<() [8/8]

template<typename TYPE >
LogMaster& Gambit::Logging::operator<< ( LogMaster logobj,
TYPE &  input 
)

Definition at line 87 of file logger.hpp.

88  {
89  using ::Gambit::operator<<; // Unhide operator overloads in Gambit scope
90  std::stringstream ss;
91  ss << input;
92  logobj << ss.str();
93  return logobj;
94  }

◆ str2tag()

int Gambit::Logging::str2tag ( const std::string &  tagname)

Definition at line 152 of file logging.cpp.

References tag2str().

Referenced by Gambit::backend_functor_common< TYPE(*)(ARGS...), TYPE, ARGS... >::backend_functor_common(), Gambit::Logging::LogMaster::initialise(), and Gambit::module_functor_common::module_functor_common().

153  {
154  for(std::map<int,std::string>::iterator tag = tag2str().begin(); tag != tag2str().end(); ++tag)
155  {
156  if (tag->second == tagname) { return tag->first; }
157  }
158  // Uh oh, no match found. Return fail code and let caller deal with it
159  return -1;
160  }
std::map< int, std::string > & tag2str()
Definition: logging.cpp:130
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tag2str()

std::map< int, std::string > & Gambit::Logging::tag2str ( )

Definition at line 130 of file logging.cpp.

Referenced by checktags(), getfreetag(), Gambit::register_module_with_log(), Gambit::Logging::SortedMessage::SortedMessage(), str2tag(), and Gambit::Logging::StdLogger::writetags().

131  {
132  // Can't be const because we will add to it from the module/backend macros
133  static std::map<int,std::string> tag2str_map = create_tag_names();
134  return tag2str_map;
135  }
Here is the caller graph for this function:

Variable Documentation

◆ verbose

const bool Gambit::Logging::verbose = false

Definition at line 52 of file logging.cpp.

Referenced by scanner_plugin().