logger.h 952 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * 2D Game Engine
  3. * Logger.h:
  4. * Based on pikuma.com 2D game engine in C++ and Lua course
  5. * Copyright (c) 2021 986-Studio. All rights reserved.
  6. *
  7. * Created by Manoël Trapier on 11/02/2021.
  8. */
  9. #ifndef GAMEENGINE_LOGGER_H
  10. #define GAMEENGINE_LOGGER_H
  11. #include <time.h>
  12. #include <vector>
  13. typedef enum LogType
  14. {
  15. LOG_LOG = 0,
  16. LOG_ERROR,
  17. LOG_WARNING,
  18. LOG_INFO,
  19. LOG_CRITICAL,
  20. LOG_DEBUG,
  21. } LogType;
  22. typedef struct LogEntry
  23. {
  24. LogType type;
  25. time_t timestamp;
  26. char *message;
  27. } LogEntry;
  28. class Logger
  29. {
  30. public:
  31. /* C++ is stupid. */
  32. static std::vector<LogEntry> messages;
  33. static void Log(const char *message, ...);
  34. static void Error(const char *message, ...);
  35. static void Warning(const char *message, ...);
  36. static void Info(const char *message, ...);
  37. static void Critical(const char *message, ...);
  38. static void Debug(const char *message, ...);
  39. };
  40. #endif /* GAMEENGINE_LOGGER_H */