Utilities
Utilities header only library
utils::LogReader Class Reference

Log - accumulate typed messages reported by the application. Includes percentage value in range <0,1>. More...

Inheritance diagram for utils::LogReader:
[legend]

Public Member Functions

 LogReader (const LogReader &)=delete
 
LogReader & operator= (const LogReader &)=delete
 
 LogReader (LogReader &&)=delete
 
LogReader & operator= (LogReader &&)=delete
 
bool IsPercentageEnabled () const
 Returns true if percentage is currently enabled. Some processing functions may not support percentage values.
 
float GetPercentage () const
 Returns current percentage value of progress in range 0, 1.
 
void SetOutputStream (std::ostream *output_log_stream)
 Allows user to specify custom output stream to receive verbose information about progress. Default value is nullptr.
 
std::ostream * GetOutputStream ()
 Returns pointer to currently active output stream.
 
std::vector< std::shared_ptr< LogEntry > > ViewUnread (const utils::EnumFlags< LogEntry::Type > &types=LogEntry::GetWECTypes()) const
 Get all unread messages specified by their types and return them.
 
std::string ViewUnreadToString (const utils::EnumFlags< LogEntry::Type > &types=LogEntry::GetIWECTypes()) const
 Get all unread messages specified by their types and return them and output as std::string.
 
std::vector< std::shared_ptr< LogEntry > > ReadUnread (const utils::EnumFlags< LogEntry::Type > &types)
 Get all unread messages specified by their types, set them to read, and return them.
 

Protected Attributes

std::ostream * output_stream_ = nullptr
 
ProgressPercentage percentage_
 
std::mutex percentage_access_
 
std::vector< std::shared_ptr< LogEntry > > log_entries_
 Saved log entries.
 
std::mutex log_access_
 mutex to ensure thread safety of the Log.
 

Detailed Description

Log - accumulate typed messages reported by the application. Includes percentage value in range <0,1>.

Is not a singleton. Multiple individual components of the application may have their own log.

Includes the functionality to inform about progress of processing functions. Whenever a function is run, this class provides thread-safe getters which can be used to inform user about current state of the function.