|
| Report ()=default |
| Default constructor.
|
|
| Report (int max_severity, const UString &prefix=UString(), Report *report=nullptr) |
| Constructor with initial report level, prefix and delegation.
|
|
virtual | ~Report () |
| Destructor.
|
|
bool | debug () const |
| Check if debugging is active.
|
|
template<class... Args> |
void | debug (const UChar *fmt, Args &&... args) |
| Report a debug message with a printf-like interface.
|
|
void | debug (const UChar *msg) |
| Report a debug message.
|
|
template<class... Args> |
void | debug (const UString &fmt, Args &&... args) |
| Report a debug message with a printf-like interface.
|
|
void | debug (const UString &msg) |
| Report a debug message.
|
|
Report * | delegateReport (Report *report) |
| Delegate message logging to another report object.
|
|
template<class... Args> |
void | error (const UChar *fmt, Args &&... args) |
| Report an error message with a printf-like interface.
|
|
void | error (const UChar *msg) |
| Report an error message.
|
|
template<class... Args> |
void | error (const UString &fmt, Args &&... args) |
| Report an error message with a printf-like interface.
|
|
void | error (const UString &msg) |
| Report an error message.
|
|
template<class... Args> |
void | fatal (const UChar *fmt, Args &&... args) |
| Report a fatal error message with a printf-like interface.
|
|
void | fatal (const UChar *msg) |
| Report a fatal error message.
|
|
template<class... Args> |
void | fatal (const UString &fmt, Args &&... args) |
| Report a fatal error message with a printf-like interface.
|
|
void | fatal (const UString &msg) |
| Report a fatal error message.
|
|
bool | gotErrors () const |
| Check if errors (or worse) were reported through this object.
|
|
template<class... Args> |
void | info (const UChar *fmt, Args &&... args) |
| Report an informational message with a printf-like interface.
|
|
void | info (const UChar *msg) |
| Report an informational message.
|
|
template<class... Args> |
void | info (const UString &fmt, Args &&... args) |
| Report an informational message with a printf-like interface.
|
|
void | info (const UString &msg) |
| Report an informational message.
|
|
template<class... Args> |
void | log (int severity, const UChar *fmt, Args &&... args) |
| Report a message with an explicit severity and a printf-like interface.
|
|
template<class... Args> |
void | log (int severity, const UString &fmt, Args &&... args) |
| Report a message with an explicit severity and a printf-like interface.
|
|
void | log (int severity, const UString &msg) |
| Report a message with an explicit severity.
|
|
int | maxSeverity () const |
| Get maximum severity level.
|
|
void | raiseMaxSeverity (int level) |
| Raise maximum severity level.
|
|
UString | reportPrefix () const |
| Get the current prefix to display.
|
|
void | resetErrors () |
| Reset the error indicator.
|
|
void | setMaxSeverity (int level) |
| Set maximum severity level.
|
|
void | setReportPrefix (const UString &prefix) |
| Set the prefix to display before each message.
|
|
template<class... Args> |
void | severe (const UChar *fmt, Args &&... args) |
| Report a severe error message with a printf-like interface.
|
|
void | severe (const UChar *msg) |
| Report a severe error message.
|
|
template<class... Args> |
void | severe (const UString &fmt, Args &&... args) |
| Report a severe error message with a printf-like interface.
|
|
void | severe (const UString &msg) |
| Report a severe error message.
|
|
bool | verbose () const |
| Check if verbose reporting is active.
|
|
template<class... Args> |
void | verbose (const UChar *fmt, Args &&... args) |
| Report a verbose message with a printf-like interface.
|
|
void | verbose (const UChar *msg) |
| Report a verbose message.
|
|
template<class... Args> |
void | verbose (const UString &fmt, Args &&... args) |
| Report a verbose message with a printf-like interface.
|
|
void | verbose (const UString &msg) |
| Report a verbose message.
|
|
template<class... Args> |
void | warning (const UChar *fmt, Args &&... args) |
| Report a warning message with a printf-like interface.
|
|
void | warning (const UChar *msg) |
| Report a warning error message.
|
|
template<class... Args> |
void | warning (const UString &fmt, Args &&... args) |
| Report a warning message with a printf-like interface.
|
|
void | warning (const UString &msg) |
| Report a warning error message.
|
|
Base class for message reporting and monitoring.
Maximum severity: Each Report instance has an adjustable "maximum severity". All messages with a higher severity are dropped without reporting. The initial default severity is Info
, meaning that Verbose
and Debug
messages are dropped by default.
Report delegation: A Report can delegate its message reporting to another Report. Each Report has at most one delegate and several delagators (other Reports which delegate to this object). Therefore, there is a tree of Reports which ultimately ends to one Report which does the actual message logging. All Reports in that tree share the same maximum severity. When the maximum severity is changed in one Report, it is updated in all Reports in the tree.
Delegation and thread synchronization: We tried to find the right balance between performances and synchronization.
- We assume that messages are extremely frequently emitted and should be logged without locking. Accesses to the current maximum severity and to the delegate are unchecked are done using local capies in this object. Problems occur when we log to the delegate at the same time the delegate is destructed, because there is no lock during the logging functions. We accept the race condition since getting the lock each time we log a message whould be too costly. To avoid this race condition, never delegate to a report which may be destructed before this object.
- Setting or removing delegation is rare and needs synchronization. Because modifications can be done upward or downward, it is difficult to find a fine-grained hierarchy of locks without risking a deadlock. Similarly, it is difficult to locate one mutex per tree of Reports because trees can be split (when a delegation is removed) or merged (when a delegation is created). Therefore, a global mutex is used for all Reports, when delegations are added or removed. This is why this must be a rare operation.
- Adjusting the maximum severity is far less frequent than logging a message. However, since we assume that many or most Reports do not have any delegate or delegators, we want to safely update their maximum severity without locking the global mutex. We do this using atomic counters. For Reports which are part of a delegation tree, we lock the global mutex and update the local copy of the maximum severity in each Report in the tree.