1
0
mirror of https://github.com/paboyle/Grid.git synced 2025-04-04 19:25:56 +01:00

Updated logging to colour code according to message type

This commit is contained in:
paboyle 2016-01-02 17:21:14 +00:00
parent 15c0022042
commit 4aac345bea
3 changed files with 43 additions and 31 deletions

View File

@ -237,25 +237,18 @@ void Grid_init(int *argc,char ***argv)
std::cout<<GridLogMessage<<"\tvComplexD : "<<sizeof(vComplexD)*8 <<"bits ; " <<GridCmdVectorIntToString(GridDefaultSimd(4,vComplexD::Nsimd()))<<std::endl;
}
std::string BLACK("\033[30m");
std::string RED("\033[31m");
std::string GREEN("\033[32m");
std::string YELLOW("\033[33m");
std::string BLUE("\033[34m");
std::string PURPLE("\033[35m");
std::string CYAN("\033[36m");
std::string WHITE("\033[37m");
std::string NORMAL("\033[0;39m");
std::cout <<std::endl;
std::cout <<GREEN<< " GGG "<<RED<<" RRRR "<<BLUE<<" IIIII "<<PURPLE<<" DDDD "<<std::endl;
std::cout <<GREEN<< " G G "<<RED<<" R R "<<BLUE<<" I "<<PURPLE<<" D D "<<std::endl;
std::cout <<GREEN<< " G "<<RED<<" R R "<<BLUE<<" I "<<PURPLE<<" D D "<<std::endl;
std::cout <<GREEN<< " G GGG"<<RED<<" RRRR "<<BLUE<<" I "<<PURPLE<<" D D "<<std::endl;
std::cout <<GREEN<< " G G "<<RED<<" R R "<<BLUE<<" I "<<PURPLE<<" D D "<<std::endl;
std::cout <<GREEN<< " GGGG "<<RED<<" R R "<<BLUE<<" IIIII "<<PURPLE<<" DDDD "<<std::endl;
std::cout <<Logger::GREEN<< " GGG "<<Logger::RED<<" RRRR "<<Logger::BLUE<<" IIIII "<<Logger::PURPLE<<" DDDD "<<std::endl;
std::cout <<Logger::GREEN<< " G G "<<Logger::RED<<" R R "<<Logger::BLUE<<" I "<<Logger::PURPLE<<" D D "<<std::endl;
std::cout <<Logger::GREEN<< " G "<<Logger::RED<<" R R "<<Logger::BLUE<<" I "<<Logger::PURPLE<<" D D "<<std::endl;
std::cout <<Logger::GREEN<< " G GGG"<<Logger::RED<<" RRRR "<<Logger::BLUE<<" I "<<Logger::PURPLE<<" D D "<<std::endl;
std::cout <<Logger::GREEN<< " G G "<<Logger::RED<<" R R "<<Logger::BLUE<<" I "<<Logger::PURPLE<<" D D "<<std::endl;
std::cout <<Logger::GREEN<< " GGGG "<<Logger::RED<<" R R "<<Logger::BLUE<<" IIIII "<<Logger::PURPLE<<" DDDD "<<std::endl;
std::cout << std::endl;
std::cout <<RED<< std::endl;
std::cout << std::endl;
std::cout <<Logger::RED<< std::endl;
std::cout << "Copyright (C) 2015 Peter Boyle, Azusa Yamaguchi, Guido Cossu, Antonin Portelli and other authors"<<std::endl;
std::cout << "Colours by Tadahito Boyle "<<std::endl;
std::cout << std::endl;
std::cout << "This program is free software; you can redistribute it and/or modify"<<std::endl;
std::cout << "it under the terms of the GNU General Public License as published by"<<std::endl;
@ -266,7 +259,7 @@ void Grid_init(int *argc,char ***argv)
std::cout << "but WITHOUT ANY WARRANTY; without even the implied warranty of"<<std::endl;
std::cout << "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"<<std::endl;
std::cout << "GNU General Public License for more details."<<std::endl;
std::cout << BLACK <<std::endl;
std::cout << Logger::BLACK <<std::endl;
}

View File

@ -34,14 +34,23 @@ namespace Grid {
GridStopWatch Logger::StopWatch;
std::ostream Logger::devnull(0);
std::string Logger::BLACK("\033[30m");
std::string Logger::RED("\033[31m");
std::string Logger::GREEN("\033[32m");
std::string Logger::YELLOW("\033[33m");
std::string Logger::BLUE("\033[34m");
std::string Logger::PURPLE("\033[35m");
std::string Logger::CYAN("\033[36m");
std::string Logger::WHITE("\033[37m");
std::string Logger::NORMAL("\033[0;39m");
GridLogger GridLogError (1,"Error");
GridLogger GridLogWarning (1,"Warning");
GridLogger GridLogMessage (1,"Message");
GridLogger GridLogDebug (1,"Debug");
GridLogger GridLogPerformance(1,"Performance");
GridLogger GridLogIterative (1,"Iterative");
GridLogger GridLogIntegrator (1,"Integrator");
GridLogger GridLogError (1,"Error",Logger::RED);
GridLogger GridLogWarning (1,"Warning",Logger::YELLOW);
GridLogger GridLogMessage (1,"Message",Logger::BLACK);
GridLogger GridLogDebug (1,"Debug",Logger::PURPLE);
GridLogger GridLogPerformance(1,"Performance",Logger::GREEN);
GridLogger GridLogIterative (1,"Iterative",Logger::BLUE);
GridLogger GridLogIntegrator (1,"Integrator",Logger::BLUE);
void GridLogConfigure(std::vector<std::string> &logstreams)
{

View File

@ -37,13 +37,23 @@ namespace Grid {
class Logger {
protected:
int active;
std::string name, topName;
std::string name, topName, COLOUR;
public:
static GridStopWatch StopWatch;
static std::ostream devnull;
static std::string BLACK;
static std::string RED ;
static std::string GREEN;
static std::string YELLOW;
static std::string BLUE ;
static std::string PURPLE;
static std::string CYAN ;
static std::string WHITE ;
static std::string NORMAL;
Logger(std::string topNm, int on, std::string nm)
: active(on), name(nm), topName(topNm) {};
Logger(std::string topNm, int on, std::string nm,std::string col)
: active(on), name(nm), topName(topNm), COLOUR(col) {};
void Active(int on) {active = on;};
int isActive(void) {return active;};
@ -53,9 +63,9 @@ public:
StopWatch.Stop();
GridTime now = StopWatch.Elapsed();
StopWatch.Start();
stream << std::setw(8) << std::left << log.topName << " : ";
stream << std::setw(12) << std::left << log.name << " : ";
stream << now << " : ";
stream << BLACK<< log.topName << BLACK<< " : ";
stream << log.COLOUR <<std::setw(10) << std::left << log.name << BLACK << " : ";
stream << YELLOW<< now <<BLACK << " : " << log.COLOUR;
return stream;
} else {
return devnull;
@ -66,7 +76,7 @@ public:
class GridLogger: public Logger {
public:
GridLogger(int on, std::string nm): Logger("Grid", on, nm){};
GridLogger(int on, std::string nm, std::string col = Logger::BLACK): Logger("Grid", on, nm, col){};
};
void GridLogConfigure(std::vector<std::string> &logstreams);