30 if( a.size() > b.size() )
std::swap(a,b) ;
31 return std::string( a.begin(), std::mismatch( a.begin(), a.end(), b.begin() ).first ) ;
66 : type_(type), every_process_(false), line_(0)
89 "Wrn",
"Msg",
"Log",
"Dbg",
"Err"};
90 int type_idx = msg_type;
93 return type_names[type_idx];
95 return type_names[type_idx + 5];
124 case MsgType::warning:
131 case MsgType::message:
145 #ifdef FLOW123D_DEBUG 172 stream << setfill(
' ');
180 std::istringstream istream(scr_stream.str());
181 while(std::getline(istream, segment)) {
185 stream << std::setw(18) <<
"";
187 stream << segment <<
"\n";
190 stream << std::flush;
198 stream << setfill(
' ');
206 std::istringstream istream(file_stream.str());
207 while(std::getline(istream, segment)) {
208 segments.push_back(segment);
210 if (segments.size() > 1) {
211 stream <<
" - |" <<
"\n";
212 for (
auto seg : segments)
213 stream << std::setw(4) <<
"" << seg <<
"\n";
214 }
else if (segments.size() == 1) {
215 stream <<
" - " << segments[0] <<
"\n";
218 stream << std::flush;
228 stream << setiosflags(ios::left) << std::setw(5) << rank.str();
230 stream << std::setw(5) <<
"";
233 if (
type_ != MsgType::message) {
244 stream <<
"- -" << std::setw(13) <<
"" <<
"[ ";
249 else stream <<
"null";
255 #ifdef FLOW123D_SOURCE_DIR Class for storing logger messages.
void print_file_header(std::ofstream &stream, std::stringstream &file_stream)
Print header to file stream, helper method called from print_to_file.
static StreamMask cout
Predefined mask of std::cout output.
std::stringstream cout_stream_
Store messages printed to cout output stream.
StreamMask streams_mask_
Mask of logger, specifies streams in actual time into which to be written.
StreamMask()
Empty constructor.
friend Logger & operator<<(Logger &log, const T &x)
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
Logger & set_context(const char *file_name, const char *function, const int line)
Stores values for printing out line number, function, etc.
std::string cmn_prefix(std::string a, std::string b)
Helper function, use for shorten the code point path.
static std::string format_hh_mm_ss()
std::stringstream cerr_stream_
Store messages printed to cerr output stream.
std::string function_
Actual function.
StreamMask operator|(const StreamMask &other)
Global macros to enhance readability and debugging, general constants.
static const std::string msg_type_string(MsgType msg_type, bool full_format=true)
Return string value of given MsgType in full or shorter format (e.g. "WARNING" of "Wrn") ...
static StreamMask cerr
Predefined mask of std::cerr output.
void print_to_file(std::ofstream &stream, std::stringstream &file_stream, StreamMask mask)
Print formated message to given file stream if mask corresponds with streams_mask_.
static StreamMask log
Predefined mask of log file output.
StreamMask operator&(const StreamMask &other)
void print_to_screen(std::ostream &stream, std::stringstream &scr_stream, StreamMask mask)
Print formated message to given screen stream if mask corresponds with streams_mask_.
Helper class, store mask specifying streams.
std::string date_time_
Actual date and time.
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
bool every_process_
Flag marked if log message is printing for all processes or only for zero process.
int get_mpi_rank()
Returns number of actual process, if MPI is not supported returns -1.
std::stringstream file_stream_
Store messages printed to file.
Logger & every_proc()
Set flag every_process_ to true.
static LoggerOptions & get_instance()
Getter of singleton instance object.
StreamMask full_streams_mask_
Mask of logger, specifies all streams into which to be written in logger message. ...
bool print_screen_header(std::ostream &stream, std::stringstream &scr_stream)
Print header to screen stream, helper method called from print_to_screen.
std::string file_name_
Actual file.
int mpi_rank_
Actual process (if MPI is supported)
MsgType type_
Type of message.
void set_mask()
Set streams_mask_ according to the type of message.
Logger(MsgType type)
Constructor.
MsgType
Enum of types of Logger messages.