logmaster.cpp
Go to the documentation of this file.
148 if (verbose) *this<<"Logger backlog buffer not empty during LogMaster destruction; attempting to deliver unsent messages to the logs..."<<EOM; 149 // If LogMaster was never initialised, create a default log file to which the messages can be dumped. 152 if (verbose) std::cout<<"Logger was never initialised! Creating default log messenger..."<<std::endl; 158 if (verbose) std::cout<<"Log messages will be delivered to '" << Utils::runtime_scratch() << "default.log'"<<std::endl; 170 // // LogMaster should not be destructed from within a parallel block. This check helps detect such a bug. 173 // // Raising an error from within the loggers within a parallel block probably will not end well, just use cout. 176 // std::cout << "rank "<<MPIrank<<": "<< LOCAL_INFO << ": Tried to destruct LogMaster from inside an omp parallel block! This should not be allowed to happen, please file a bug report." << std::endl; 183 // Check if there is anything in the output stream that has not been sent, and send it if there is 184 // (these messages will get backlogged because they are sent (ended) from a parallel block, but we are 193 *this <<"#### NO EOM RECEIVED FOR MESSAGE FROM THREAD ("<<i<<"): MESSAGE MAY BE INCOMPLETE ####"<<warn<<EOM; 204 for(std::map<std::set<int>,BaseLogger*>::iterator keyvalue = loggers.begin(); keyvalue != loggers.end(); ++keyvalue) 207 // (not sure if this is really needed, I think the message is in the operating systems domain by this point) 222 // This is the function that yaml_parser.hpp uses. You provide tags as a set of strings, and the filename as a string. We then construct the logger objects in here. 223 void LogMaster::initialise(std::vector<std::pair< std::set<std::string>, std::string >>& loggerinfo) 237 // NOTE! Option to merge log files no longer exists. Concurrent write access is a nightmare. Log messages were 238 // being lost due to different processes overwriting each others data, and using the FileLock system doesn't 239 // help because the issue is the file pointer location. To fix that, files have to be closed and reopened 240 // constantly, which creates a lot of overhead. On top of this, it is very hard to overwrite old log files at the 241 // beginning of the run since we have to coordinate who creates the file at the beginning of the run, would have 245 // if(separate_file_per_process){ std::cout << "true; log messages will be stored in separate files for each MPI process (filename will be appended with underscore + MPI rank)"; } 246 // else{ std::cout << "false; log messages from separate MPI processes will be merged into one file (orchestrated by the OS; some mangling of concurrently written log messages may occur. Set this separate_file_per_process to 'True' if this mangling is a problem for you)";} 250 if(log_debug_messages) logmsg << "true; log messages tagged as 'Debug' WILL be logged. " << endl << "WARNING: This may lead to very large log files!"; 262 for(std::vector<std::pair< std::set<std::string>, std::string >>::iterator infopair = loggerinfo.begin(); 290 // If we didn't find the tag, raise an exception (probably means there was an error in the yaml file) 342 // Overload for initialise, to make it easier to manually initialise the logger in standalone modules 383 // // Raising an error from within the loggers within a parallel block probably will not end well, just use cout. 386 // std::cout << LOCAL_INFO << ": (rank "<<MPIrank<<") Tried to run empty_backlog() (in LogMaster) from inside an omp parallel block! This should not be possible, please file a bug report." << std::endl; 433 void LogMaster::send(const std::string& message, LogTag tag1, LogTag tag2, LogTag tag3, LogTag tag4) 443 void LogMaster::send(const std::string& message, LogTag tag1, LogTag tag2, LogTag tag3, LogTag tag4, LogTag tag5) 487 void LogMaster::send(const std::ostringstream& message, LogTag tag1, LogTag tag2, LogTag tag3, LogTag tag4) 497 void LogMaster::send(const std::ostringstream& message, LogTag tag1, LogTag tag2, LogTag tag3, LogTag tag4, LogTag tag5) 527 // Ok this is the function that actual does things; the above are all just "syntatic sugar", as the cool kids say. 531 // LogMaster keeps an internal map of all the logging objects, where the keys are sets of 'LogTag's, constructed according to the inifile. So to figure out where the message has to go, we just compare the "tags" to these keys; if any of these keys are a subset of our tags, then we send the message to that LogHub. 532 // Well almost. We have to seperate out the components first, because we can "send" a message to multiple components at once, but a direction command will never include two component tags (it is an error if it does). 542 // Automatically add the "def" (Default) tag so that the message definitely tries to go somewhere 548 //std::cout<<"current_module="<<current_module<<"; adding tag "<<tag2str()[current_module]<<std::endl; 553 //std::cout<<"current_backend="<<current_backend<<"; adding tag "<<tag2str()[current_backend]<<std::endl; 572 // Check the 'ignore' set; if any of the specified tags are in this set, then do nothing more, i.e. ignore the message. 593 for(std::map<std::set<int>,BaseLogger*>::iterator keyvalue = loggers.begin(); keyvalue != loggers.end(); ++keyvalue) std::deque< Message > * backlog Messages sent before logger objects are created will be buffered Same for messages sent while inside ... Definition: logmaster.hpp:183 structure for storing log messages and metadata after tags are sorted Definition: logging.hpp:89 void init_memory() Initialise dynamic memory required for thread safety. Definition: logmaster.cpp:93 bool loggers_readyQ Flag to set whether loggers have been initialised not. Definition: logmaster.hpp:153 void send(const std::string &) Main logging function (user-friendly overloaded version) Definition: logmaster.cpp:403 Header for logging classes. Helper functions for dealing with POSIX signals. std::map< std::set< int >, BaseLogger * > loggers Map to identify loggers. Definition: logmaster.hpp:147 void entering_module(int) Set the internal variables tracking which module and/or backend is currently running. Definition: logmaster.cpp:616 void emit_backlog(bool verbose) Print the backlogs to the default log file. Definition: logmaster.cpp:137 ~LogMaster() Destructor If errors happen before the inifile is loaded, we need to dump the log messages (that have... Definition: logmaster.cpp:167 General small utility functions. Definition: log_tags.hpp:35 Definition: log_tags.hpp:44 Definition: log_tags.hpp:48 void empty_backlog() Empty the backlog buffer to the 'send' function. Definition: logmaster.cpp:378 Definition: log_tags.hpp:37 const Logging::endofmessage EOM Explicit const instance of the end of message struct in Gambit namespace. Definition: logger.hpp:99 std::ostringstream * stream Buffer variables needed for stream logging. Definition: logmaster.hpp:178 bool is_disjoint(const Set1 &set1, const Set2 &set2) Test if two sets are disjoint (works on any sorted std container I think) Definition: util_functions.hpp:155 std::set< int > ignore Global ignore set; if these tags/integers are seen, ignore messages containing them. Definition: logmaster.hpp:150 void initialise(std::vector< std::pair< std::set< std::string >, std::string >> &) Function to construct loggers according to blueprint. Definition: logmaster.cpp:223 Header for logging classes. Special (empty) struct for signalling end of message to LogMaster stream. Definition: logger.hpp:43 bool separate_file_per_process Flag to store log messages for different processes in separate files. Definition: logmaster.hpp:159 EXPORT_SYMBOLS const str & runtime_scratch() Return the path the the run-specific scratch directory. Definition: util_functions.cpp:58 A simple C++ wrapper for the MPI C bindings. EXPORT_SYMBOLS std::vector< str > delimiterSplit(str s, str delim) Split a string into a vector of strings, using a delimiter, and removing any whitespace around the de... Definition: util_functions.cpp:71 Exception objects required for standalone compilation. void input(const std::string &) Functions for stream input (actual stream operators which use these are defined in logger... Definition: logmaster.cpp:667 int globlMaxThreads Max number of threads that could potentially be running. Definition: logmaster.hpp:169 Definition: log_tags.hpp:46 Definition: log_tags.hpp:43 void finalsend(const Message &) Version of send function used by buffer dump; skips all the tag modification stuff. Definition: logmaster.cpp:570 |