CombineHarvester
Logging.h File Reference
#include <string>
#include <iostream>
#include <chrono>

Go to the source code of this file.

Data Structures

class  ch::FnTimer
 Determine the total amount of time spent in a function. More...
 
class  ch::FnTimer::Token
 

Namespaces

 ch
 

Macros

#define FNERROR(x)   ch::FnError(x, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
#define LOGLINE(x, y)   LogLine(x, __func__, y)
 
#define FNLOG(x)   x << "[" << __func__ << "] "
 
#define FNLOGC(x, y)   if (y) x << "[" << __func__ << "] "
 
#define LAUNCH_FUNCTION_TIMER(x, y)
 Conveniently initialise a ch::FnTimer instance. More...
 

Functions

void ch::LogLine (std::ostream &stream, std::string const &func, std::string const &message)
 Writes a logging message to a given ostream. More...
 
std::string ch::FnError (std::string const &message, std::string const &file, unsigned line, std::string const &fn)
 Generates an error message which includes the name of the calling function and the filename and line number where the error occured. More...
 
std::string ch::GetQualififedName (std::string const &str)
 Extracts the fully-qualified function name from a complete function signature. More...
 

Macro Definition Documentation

◆ FNERROR

#define FNERROR (   x)    ch::FnError(x, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 9 of file Logging.h.

◆ LOGLINE

#define LOGLINE (   x,
 
)    LogLine(x, __func__, y)

Definition at line 11 of file Logging.h.

◆ FNLOG

#define FNLOG (   x)    x << "[" << __func__ << "] "

Definition at line 13 of file Logging.h.

◆ FNLOGC

#define FNLOGC (   x,
 
)    if (y) x << "[" << __func__ << "] "

Definition at line 14 of file Logging.h.

◆ LAUNCH_FUNCTION_TIMER

#define LAUNCH_FUNCTION_TIMER (   x,
 
)
Value:
static FnTimer x(ch::GetQualififedName(__PRETTY_FUNCTION__)); \
auto y = x.Inc();
std::string GetQualififedName(std::string const &str)
Extracts the fully-qualified function name from a complete function signature.
Definition: Logging.cc:8

Conveniently initialise a ch::FnTimer instance.

This macro should be placed at the start of a function, e.g.:

void MyFunction() {
 LAUNCH_FUNCTION_TIMER(__timer__, __token__)
}

The arguments are the names of two objects (a ch::FnTimer and a ch::FnTimer::Token) that will be created by this macro. Note that the ch::FnTimer will be assigned the current function name automatically.

Definition at line 67 of file Logging.h.