From 8709117aea51addcf6b8e9397b8ed04f14b68bbf Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 27 Oct 2015 17:31:13 +0000 Subject: [PATCH] Log: generalised Logger class to allow separate logs in Grid-based applications --- lib/Log.cc | 4 ++-- lib/Log.h | 54 +++++++++++++++++++++++++++++++----------------------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/lib/Log.cc b/lib/Log.cc index 468d9116..8aa0b809 100644 --- a/lib/Log.cc +++ b/lib/Log.cc @@ -2,8 +2,8 @@ namespace Grid { -GridStopWatch GridLogger::StopWatch; -std::ostream GridLogger::devnull(0); +GridStopWatch Logger::StopWatch; +std::ostream Logger::devnull(0); GridLogger GridLogError (1,"Error"); GridLogger GridLogWarning (1,"Warning"); diff --git a/lib/Log.h b/lib/Log.h index 4cf094bc..eaadfd81 100644 --- a/lib/Log.h +++ b/lib/Log.h @@ -6,31 +6,39 @@ namespace Grid { std::ostream& operator<< (std::ostream& stream, const GridTime& time); -class GridLogger { - int active; - std::string name; +class Logger { +protected: + int active; + std::string name, topName; 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 : "< &logstreams);