From 48282260956b914eae53ab0b32774bbbfc4e4334 Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 27 Feb 2018 14:43:51 +0000 Subject: [PATCH] Hadrons: prettier log --- extras/Hadrons/Global.cc | 17 ++++++++++++++++- lib/log/Log.h | 10 ++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/extras/Hadrons/Global.cc b/extras/Hadrons/Global.cc index b121434f..0164a1ab 100644 --- a/extras/Hadrons/Global.cc +++ b/extras/Hadrons/Global.cc @@ -41,19 +41,34 @@ HadronsLogger Hadrons::HadronsLogIRL(1,"IRL"); void Hadrons::initLogger(void) { - auto w = std::string("Hadrons").length(); + auto w = std::string("Hadrons").length(); + int cw = 8; + + GridLogError.setTopWidth(w); GridLogWarning.setTopWidth(w); GridLogMessage.setTopWidth(w); GridLogIterative.setTopWidth(w); GridLogDebug.setTopWidth(w); GridLogIRL.setTopWidth(w); + GridLogError.setChanWidth(cw); + GridLogWarning.setChanWidth(cw); + GridLogMessage.setChanWidth(cw); + GridLogIterative.setChanWidth(cw); + GridLogDebug.setChanWidth(cw); + GridLogIRL.setChanWidth(cw); HadronsLogError.Active(GridLogError.isActive()); HadronsLogWarning.Active(GridLogWarning.isActive()); HadronsLogMessage.Active(GridLogMessage.isActive()); HadronsLogIterative.Active(GridLogIterative.isActive()); HadronsLogDebug.Active(GridLogDebug.isActive()); HadronsLogIRL.Active(GridLogIRL.isActive()); + HadronsLogError.setChanWidth(cw); + HadronsLogWarning.setChanWidth(cw); + HadronsLogMessage.setChanWidth(cw); + HadronsLogIterative.setChanWidth(cw); + HadronsLogDebug.setChanWidth(cw); + HadronsLogIRL.setChanWidth(cw); } // type utilities ////////////////////////////////////////////////////////////// diff --git a/lib/log/Log.h b/lib/log/Log.h index 011a7250..b58c5d16 100644 --- a/lib/log/Log.h +++ b/lib/log/Log.h @@ -86,7 +86,7 @@ protected: Colours &Painter; int active; int timing_mode; - int topWidth{-1}; + int topWidth{-1}, chanWidth{-1}; static int timestamp; std::string name, topName; std::string COLOUR; @@ -126,6 +126,7 @@ public: } } void setTopWidth(const int w) {topWidth = w;} + void setChanWidth(const int w) {chanWidth = w;} friend std::ostream& operator<< (std::ostream& stream, Logger& log){ @@ -136,7 +137,12 @@ public: stream << std::setw(log.topWidth); } stream << log.topName << log.background()<< " : "; - stream << log.colour() << std::left << log.name << log.background() << " : "; + stream << log.colour() << std::left; + if (log.chanWidth > 0) + { + stream << std::setw(log.chanWidth); + } + stream << log.name << log.background() << " : "; if ( log.timestamp ) { log.StopWatch->Stop(); GridTime now = log.StopWatch->Elapsed();