diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-01-02 13:54:34 -0800 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-01-02 13:54:34 -0800 |
commit | 2cb567edc01a251bd6e3216113313b0c94bced95 (patch) | |
tree | cd795fbf99bab32b19ba986c995c4e7c350090e6 | |
parent | f43da413f0fe1ef4686fcbfa05a97af9a211d217 (diff) |
Adding the ability for Printer to override globals.
-rw-r--r-- | includes/Printer.h | 7 | ||||
-rw-r--r-- | src/Printer.cc | 4 |
2 files changed, 7 insertions, 4 deletions
diff --git a/includes/Printer.h b/includes/Printer.h index 2717a84..f1897d3 100644 --- a/includes/Printer.h +++ b/includes/Printer.h @@ -44,10 +44,6 @@ enum { }; class Printer { - protected: - virtual void _print(const char * fmt, va_list ap); - - private: void _print(const char * fmt, ...); void _log(uint32_t level, const char * fmt, va_list ap); @@ -56,6 +52,7 @@ class Printer { Printer(); void setLocal(); + void setGlobal(); static Printer * getPrinter(); static void log(uint32_t level, const String & fmt, ...) { va_list ap; va_start(ap, fmt); vlog(level, fmt.to_charp(), ap); va_end(ap); } @@ -76,6 +73,8 @@ class Printer { static void setDetailled(bool enable) { getPrinter()->m_detailledLogs = enable; } + virtual void _print(const char * fmt, va_list ap); + private: uint32_t m_verbosity = M_STATUS | M_WARNING | M_ERROR | M_ENGINE_DEBUG; bool m_detailledLogs = false; diff --git a/src/Printer.cc b/src/Printer.cc index a7fee9f..7eb02d8 100644 --- a/src/Printer.cc +++ b/src/Printer.cc @@ -28,6 +28,10 @@ void Balau::Printer::setLocal() { localPrinter.set(this); } +void Balau::Printer::setGlobal() { + localPrinter.setGlobal(this); +} + Balau::Printer * Balau::Printer::getPrinter() { return localPrinter.get(); } void Balau::Printer::_log(uint32_t level, const char * fmt, va_list ap) { |