diff options
author | Andreas Haas <Hinsbart@users.noreply.github.com> | 2017-10-02 23:51:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-02 23:51:26 +0200 |
commit | 132ba0ed9799db9ed1449fa2f2fc597d4b91612d (patch) | |
tree | b0c62cdc864e64636fa6717438025fbd9a35fb04 /platform/android/os_android.cpp | |
parent | de9cc6ed96c79c70ca9cf22830b3e42cca4f244b (diff) | |
parent | 1a2311e3505765e37b736fe6bb46bb229e00701f (diff) |
Merge pull request #11568 from endragor/loggers
Extract logging logic
Diffstat (limited to 'platform/android/os_android.cpp')
-rw-r--r-- | platform/android/os_android.cpp | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index dbea2d7531..0eb14f6af3 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -47,6 +47,15 @@ #include "file_access_jandroid.h" #endif +class AndroidLogger : public Logger { +public: + virtual void logv(const char *p_format, va_list p_list, bool p_err) { + __android_log_vprint(p_err ? ANDROID_LOG_ERROR : ANDROID_LOG_INFO, "godot", p_format, p_list); + } + + virtual ~AndroidLogger() {} +}; + int OS_Android::get_video_driver_count() const { return 1; @@ -111,6 +120,13 @@ void OS_Android::initialize_core() { #endif } +void OS_Android::initialize_logger() { + Vector<Logger *> loggers; + loggers.push_back(memnew(AndroidLogger)); + loggers.push_back(memnew(RotatedFileLogger("user://logs/log.txt"))); + _set_logger(memnew(CompositeLogger(loggers))); +} + void OS_Android::set_opengl_extensions(const char *p_gl_extensions) { ERR_FAIL_COND(!p_gl_extensions); @@ -162,23 +178,9 @@ void OS_Android::delete_main_loop() { } void OS_Android::finalize() { - memdelete(input); } -void OS_Android::vprint(const char *p_format, va_list p_list, bool p_stderr) { - - __android_log_vprint(p_stderr ? ANDROID_LOG_ERROR : ANDROID_LOG_INFO, "godot", p_format, p_list); -} - -void OS_Android::print(const char *p_format, ...) { - - va_list argp; - va_start(argp, p_format); - __android_log_vprint(ANDROID_LOG_INFO, "godot", p_format, argp); - va_end(argp); -} - void OS_Android::alert(const String &p_alert, const String &p_title) { //print("ALERT: %s\n", p_alert.utf8().get_data()); @@ -737,6 +739,8 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURI set_keep_screen_on_func = p_set_keep_screen_on_func; alert_func = p_alert_func; use_reload_hooks = false; + + _set_logger(memnew(AndroidLogger)); } OS_Android::~OS_Android() { |