SHARE
TWEET

Untitled

a guest May 13th, 2014 305 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/src/Engine/Logger.h b/src/Engine/Logger.h
  2. index b0262da..f6be037 100644
  3. --- a/src/Engine/Logger.h
  4. +++ b/src/Engine/Logger.h
  5. @@ -69,6 +69,7 @@
  6.      static SeverityLevel& reportingLevel();
  7.         static std::string& logFile();
  8.      static std::string toString(SeverityLevel level);
  9. +    static std::string toColor(SeverityLevel level);
  10.  protected:
  11.      std::ostringstream os;
  12.  private:
  13. @@ -81,7 +82,7 @@
  14.  }
  15.  
  16.  inline std::ostringstream& Logger::get(SeverityLevel level)
  17. -{
  18. +{   os << toColor(level);
  19.         os << "[" << toString(level) << "]" << "\t";
  20.      return os;
  21.  }
  22. @@ -95,7 +96,7 @@
  23.                 fflush(stderr);
  24.         }
  25.         std::ostringstream ss;
  26. -       ss << "[" << now() << "]" << "\t" << os.str();
  27. +       ss << "[" << now() << "]" << "\t" << os.str() << "\033[0m"; // Reset the coloring
  28.         FILE *file = fopen(logFile().c_str(), "a");
  29.         fprintf(file, "%s", ss.str().c_str());
  30.      fflush(file);
  31. @@ -120,6 +121,13 @@
  32.      return buffer[level];
  33.  }
  34.  
  35. +inline std::string Logger::toColor(SeverityLevel level)
  36. +{
  37. +    // Error levels:                     FATAL       ERROR       WARN           INFO           DEBUG
  38. +    static const char* const buffer[] = {"\033[35m", "\033[31m", "\033[33m", "\033[32m", "\033[0m"};
  39. +    return buffer[level];
  40. +}
  41. +
  42.  #define Log(level) \
  43.      if (level > Logger::reportingLevel()) ; \
  44.      else Logger().get(level)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top