ShishGL  1.0
A simple modular cross-platform graphics library
LogSystem.hpp
Go to the documentation of this file.
1 /*============================================================================*/
2 #ifndef SHISHGL_LOG_SYSTEM_HPP
3 #define SHISHGL_LOG_SYSTEM_HPP
4 /*============================================================================*/
5 #include <cstdio>
6 #include <cstdarg>
7 
8 #include "Time.hpp"
9 /*============================================================================*/
10 namespace Sh {
11 
12  class LogSystem {
13  public:
14 
15  typedef enum {
16  LOG_OK = 0,
23 
24  /*--------------------------------------------------------------------*/
25 
26  static LogStatus printLog(const char* format, ...)
27  __attribute__((format(printf, 1, 2)));
28 
29  static LogStatus printWarning(const char* format, ...)
30  __attribute__((format(printf, 1, 2)));
31 
32  static LogStatus printError(const char* format, ...)
33  __attribute__((format(printf, 1, 2)));
34 
35  static void flush();
36 
37  /*--------------------------------------------------------------------*/
38 
39  virtual ~LogSystem() = default;
40 
41  private:
42 
43  LogSystem() = default;
44 
45  /*--------------------------------------------------------------------*/
46 
47  static LogStatus openLog();
48 
49  static LogStatus closeLog();
50 
51  static LogStatus print(const TimeDelta& elapsed,
52  const char* format, va_list args);
53 
54  /*--------------------------------------------------------------------*/
55  static FILE* LOG_FILE;
56 
57  static constexpr size_t BUFFER_SIZE = 4096;
58 
59  struct Message {
60 
61  char buffer[BUFFER_SIZE];
62  size_t cnt;
63 
64  TimeDelta begin;
65  TimeDelta end;
66 
67  };
68 
69  static Message& LastMessage();
70  /*--------------------------------------------------------------------*/
71 
72  static Timer& RunTimer();
73 
74  friend class CoreApplication;
75  };
76 
77 }
78 /*============================================================================*/
79 #endif //SHISHGL_LOG_SYSTEM_HPP
80 /*============================================================================*/
Sh::LogSystem::LOG_OK
@ LOG_OK
Definition: LogSystem.hpp:16
Sh::CoreApplication
Definition: CoreApplication.hpp:15
Sh::LogSystem::flush
static LogStatus static LogStatus static LogStatus static void flush()
Definition: LogSystem.cpp:148
Sh::LogSystem::printWarning
static LogStatus static LogStatus printWarning(const char *format,...) __attribute__((format(printf
Definition: LogSystem.cpp:81
Sh::LogSystem::LOG_CLOSE_ERR
@ LOG_CLOSE_ERR
Definition: LogSystem.hpp:19
Sh::LogSystem
Definition: LogSystem.hpp:12
Sh::LogSystem::LOG_ALREADY_OPENED
@ LOG_ALREADY_OPENED
Definition: LogSystem.hpp:18
Sh
Definition: CoreApplication.hpp:10
Time.hpp
Sh::LogSystem::LOG_FILE_BROKEN
@ LOG_FILE_BROKEN
Definition: LogSystem.hpp:20
Sh::LogSystem::LOG_PRINT_ERR
@ LOG_PRINT_ERR
Definition: LogSystem.hpp:21
Sh::LogSystem::LOG_OPEN_ERR
@ LOG_OPEN_ERR
Definition: LogSystem.hpp:17
Sh::TimeDelta
Clock::duration TimeDelta
Definition: Time.hpp:11
Sh::LogSystem::printLog
static LogStatus printLog(const char *format,...) __attribute__((format(printf
Definition: LogSystem.cpp:65
Sh::LogSystem::printError
static LogStatus static LogStatus static LogStatus printError(const char *format,...) __attribute__((format(printf
Definition: LogSystem.cpp:97
Sh::LogSystem::LogStatus
LogStatus
Definition: LogSystem.hpp:15
Sh::Timer
Definition: Time.hpp:15