diff options
author | Ruslan Mustakov <r.mustakov@gmail.com> | 2017-09-22 12:56:02 +0700 |
---|---|---|
committer | Ruslan Mustakov <r.mustakov@gmail.com> | 2017-09-25 16:19:21 +0700 |
commit | 1a2311e3505765e37b736fe6bb46bb229e00701f (patch) | |
tree | fd592573dbe7d95b89649eaa677bef54336c648e /core/os/os.h | |
parent | 14b4ad931f54c73aff9021a1314943278295e602 (diff) | |
download | redot-engine-1a2311e3505765e37b736fe6bb46bb229e00701f.tar.gz |
Extract logging logic
Previously logging logic was scattered over OS class implementations
with plenty of duplication. Major changes in this commit:
- Extracted logging logic into a separate Logger hierarchy. It allows
easy configuration of logging mechanism depending on compile-time or
run-time configuration.
- Implemented RotatedFileLogger which is usually used with StdLogger,
providing persistency of logs. It is often important to be able to
obtain logs of the game even in production to be able to understand
what happened prior to some problem. On mobile there previously was
no way to obtain the logs aside from having the device connected to
your machine.
- flush() is not performed in release mode for every logged line. It
is only performed for errors.
Diffstat (limited to 'core/os/os.h')
-rw-r--r-- | core/os/os.h | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/core/os/os.h b/core/os/os.h index 38bbbc0a57..0b62290540 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -32,6 +32,7 @@ #include "engine.h" #include "image.h" +#include "io/logger.h" #include "list.h" #include "os/main_loop.h" #include "ustring.h" @@ -61,6 +62,11 @@ class OS { void *_stack_bottom; + Logger *_logger; + +protected: + void _set_logger(Logger *p_logger); + public: typedef void (*ImeCallback)(void *p_inp, String p_text, Point2 p_selection); @@ -108,6 +114,7 @@ protected: virtual int get_audio_driver_count() const = 0; virtual const char *get_audio_driver_name(int p_driver) const = 0; + virtual void initialize_logger(); virtual void initialize_core() = 0; virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) = 0; @@ -127,18 +134,10 @@ public: static OS *get_singleton(); - enum ErrorType { - ERR_ERROR, - ERR_WARNING, - ERR_SCRIPT, - ERR_SHADER - }; - - virtual void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, ErrorType p_type = ERR_ERROR); + void print_error(const char *p_function, const char *p_file, int p_line, const char *p_code, const char *p_rationale, Logger::ErrorType p_type = Logger::ERR_ERROR); + void print(const char *p_format, ...); + void printerr(const char *p_format, ...); - virtual void print(const char *p_format, ...); - virtual void printerr(const char *p_format, ...); - virtual void vprint(const char *p_format, va_list p_list, bool p_stderr = false) = 0; virtual void alert(const String &p_alert, const String &p_title = "ALERT!") = 0; virtual String get_stdin_string(bool p_block = true) = 0; |