mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
47 lines
1.0 KiB
C
47 lines
1.0 KiB
C
|
#ifndef GRID_LOG_H
|
||
|
#define GRID_LOG_H
|
||
|
namespace Grid {
|
||
|
|
||
|
// Dress the output; use std::chrono for time stamping via the StopWatch class
|
||
|
|
||
|
std::ostream& operator<< (std::ostream& stream, const GridTime& time);
|
||
|
|
||
|
class GridLogger {
|
||
|
int active;
|
||
|
std::string name;
|
||
|
public:
|
||
|
|
||
|
static GridStopWatch StopWatch;
|
||
|
static std::ostream devnull;
|
||
|
|
||
|
GridLogger(int on, std::string nm): active(on), name(nm) {
|
||
|
};
|
||
|
|
||
|
void Active(int on) {active = on;};
|
||
|
|
||
|
friend std::ostream& operator<< (std::ostream& stream, const GridLogger& log){
|
||
|
if ( log.active ) {
|
||
|
StopWatch.Stop();
|
||
|
GridTime now = StopWatch.Elapsed();
|
||
|
StopWatch.Start();
|
||
|
stream << "Grid : "<<log.name << " : " << now << " : ";
|
||
|
return stream;
|
||
|
} else {
|
||
|
return devnull;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
};
|
||
|
|
||
|
void GridLogConfigure(std::vector<std::string> &logstreams);
|
||
|
|
||
|
extern GridLogger GridLogError;
|
||
|
extern GridLogger GridLogWarning;
|
||
|
extern GridLogger GridLogMessage;
|
||
|
extern GridLogger GridLogDebug ;
|
||
|
extern GridLogger GridLogPerformance;
|
||
|
extern GridLogger GridLogIterative ;
|
||
|
|
||
|
}
|
||
|
#endif
|