2
0

Log.pkg 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. $#include "Log.h"
  2. /// Debug message level. By default only shown in debug mode.
  3. static const int LOG_DEBUG;
  4. /// Informative message level.
  5. static const int LOG_INFO;
  6. /// Warning message level.
  7. static const int LOG_WARNING;
  8. /// Error message level.
  9. static const int LOG_ERROR;
  10. /// Disable all log messages.
  11. static const int LOG_NONE;
  12. /// Logging subsystem.
  13. class Log : public Object
  14. {
  15. public:
  16. /// Set logging level.
  17. void SetLevel(int level);
  18. /// Set whether to timestamp log messages.
  19. void SetTimeStamp(bool enable);
  20. /// Set quiet mode ie. only print error entries to standard error stream (which is normally redirected to console also). Output to log file is not affected by this mode.
  21. void SetQuiet(bool quiet);
  22. /// Return logging level.
  23. int GetLevel() const { return level_; }
  24. /// Return whether log messages are timestamped.
  25. bool GetTimeStamp() const { return timeStamp_; }
  26. /// Return last log message.
  27. /// Return whether log is in quiet mode (only errors printed to standard error stream).
  28. bool IsQuiet() const { return quiet_; }
  29. /// Write to the log. If logging level is higher than the level of the message, the message is ignored.
  30. static void Write(int level, const char* message);
  31. /// Write raw output to the log.
  32. static void WriteRaw(const char* message, bool error = false);
  33. };