aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorJohannes Schickel2010-11-18 19:12:14 +0000
committerJohannes Schickel2010-11-18 19:12:14 +0000
commite1030e53a537677c234ad39de419fb97b88a37b7 (patch)
treeefa0f61d219a9de5299567c92f80662a7e5fb272 /backends
parent411866ee1881d248400da25f1889ad872ed54ee3 (diff)
downloadscummvm-rg350-e1030e53a537677c234ad39de419fb97b88a37b7.tar.gz
scummvm-rg350-e1030e53a537677c234ad39de419fb97b88a37b7.tar.bz2
scummvm-rg350-e1030e53a537677c234ad39de419fb97b88a37b7.zip
BACKENDS: Implement logging API proposed by Max on -devel.
This commits a slightly modified patch from my patch tracker item #3104630 "OSYSTEM: Add logging API as proposed by Max on -devel". I was not able to test compilation on Android and SamsungTV, since there is no toolchain for those on buildbot (or I was too blind to find them). svn-id: r54339
Diffstat (limited to 'backends')
-rw-r--r--backends/platform/android/android.cpp18
-rw-r--r--backends/platform/psp/osys_psp.cpp7
-rw-r--r--backends/platform/psp/osys_psp.h2
-rw-r--r--backends/platform/samsungtv/samsungtv.cpp5
-rw-r--r--backends/platform/samsungtv/samsungtv.h1
-rw-r--r--backends/platform/sdl/sdl.cpp24
-rw-r--r--backends/platform/sdl/sdl.h3
7 files changed, 60 insertions, 0 deletions
diff --git a/backends/platform/android/android.cpp b/backends/platform/android/android.cpp
index 38f387b201..7a4ae24e6b 100644
--- a/backends/platform/android/android.cpp
+++ b/backends/platform/android/android.cpp
@@ -299,6 +299,7 @@ public:
virtual void getTimeAndDate(TimeDate &t) const;
virtual Common::TimerManager *getTimerManager();
virtual FilesystemFactory *getFilesystemFactory();
+ virtual void logMessage(LogMessageType::Type type, const char *message);
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority = 0);
};
@@ -1266,6 +1267,23 @@ void OSystem_Android::addSysArchivesToSearchSet(Common::SearchSet &s,
}
}
+void OSystem_Android::logMessage(LogMessageType::Type type, const char *message) {
+ switch (type) {
+ case LogMessageType::kDebug:
+ BaseBackend::logMessage(type, message);
+ break;
+
+ case LogMessageType::kWarning:
+ __android_log_write(ANDROID_LOG_WARN, "ScummVM", message);
+ break;
+
+ case LogMessageType::kError:
+ // FIXME: From the name it looks like this will also quit the program.
+ // This shouldn't do that though.
+ __android_log_assert("Fatal error", "ScummVM", "%s", message);
+ break;
+ }
+}
static jint ScummVM_scummVMMain(JNIEnv* env, jobject self, jobjectArray args) {
OSystem_Android* cpp_obj = OSystem_Android::fromJavaObject(env, self);
diff --git a/backends/platform/psp/osys_psp.cpp b/backends/platform/psp/osys_psp.cpp
index 40c074ae00..df330b0b00 100644
--- a/backends/platform/psp/osys_psp.cpp
+++ b/backends/platform/psp/osys_psp.cpp
@@ -408,6 +408,13 @@ void OSystem_PSP::quit() {
sceKernelExitGame();
}
+void OSystem_PSP::logMessage(LogMessageType::Type type, const char *message) {
+ BaseBackend::logMessage(type, message);
+
+ if (type == LogMessageType::kError)
+ PspDebugTrace(false, "%s", message); // write to file
+}
+
void OSystem_PSP::getTimeAndDate(TimeDate &td) const {
time_t curTime = time(0);
struct tm t = *localtime(&curTime);
diff --git a/backends/platform/psp/osys_psp.h b/backends/platform/psp/osys_psp.h
index 52b8f4e887..d21c7e78ef 100644
--- a/backends/platform/psp/osys_psp.h
+++ b/backends/platform/psp/osys_psp.h
@@ -153,6 +153,8 @@ public:
void quit();
+ void logMessage(LogMessageType::Type type, const char *message);
+
Common::SeekableReadStream *createConfigReadStream();
Common::WriteStream *createConfigWriteStream();
diff --git a/backends/platform/samsungtv/samsungtv.cpp b/backends/platform/samsungtv/samsungtv.cpp
index aa79b92558..909734d719 100644
--- a/backends/platform/samsungtv/samsungtv.cpp
+++ b/backends/platform/samsungtv/samsungtv.cpp
@@ -54,4 +54,9 @@ bool OSystem_SDL_SamsungTV::getFeatureState(Feature f) {
}
}
+void OSystem_SDL_SamsungTV::fatalError() {
+ // FIXME
+ for (;;) {}
+}
+
#endif
diff --git a/backends/platform/samsungtv/samsungtv.h b/backends/platform/samsungtv/samsungtv.h
index b3344385aa..59d1c24cbe 100644
--- a/backends/platform/samsungtv/samsungtv.h
+++ b/backends/platform/samsungtv/samsungtv.h
@@ -43,6 +43,7 @@ public:
virtual void setFeatureState(Feature f, bool enable);
virtual bool getFeatureState(Feature f);
+ virtual void fatalError();
protected:
virtual bool remapKey(SDL_Event &ev, Common::Event &event);
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp
index 2e3819f6f5..8a139e5c1b 100644
--- a/backends/platform/sdl/sdl.cpp
+++ b/backends/platform/sdl/sdl.cpp
@@ -562,6 +562,30 @@ void OSystem_SDL::quit() {
#endif
}
+void OSystem_SDL::logMessage(LogMessageType::Type type, const char *message) {
+ BaseBackend::logMessage(type, message);
+
+#if defined( USE_WINDBG )
+#if defined( _WIN32_WCE )
+ TCHAR buf_unicode[1024];
+ MultiByteToWideChar(CP_ACP, 0, message, strlen(message) + 1, buf_unicode, sizeof(buf_unicode));
+ OutputDebugString(buf_unicode);
+
+ if (type == LogMessageType::kError) {
+#ifndef DEBUG
+ drawError(message);
+#else
+ int cmon_break_into_the_debugger_if_you_please = *(int *)(message + 1); // bus error
+ printf("%d", cmon_break_into_the_debugger_if_you_please); // don't optimize the int out
+#endif
+ }
+
+#else
+ OutputDebugString(message);
+#endif
+#endif
+}
+
void OSystem_SDL::setupIcon() {
int x, y, w, h, ncols, nbytes, i;
unsigned int rgba[256];
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h
index b701824517..328bb03426 100644
--- a/backends/platform/sdl/sdl.h
+++ b/backends/platform/sdl/sdl.h
@@ -191,6 +191,9 @@ public:
// Quit
virtual void quit(); // overloaded by CE backend
+ // Logging
+ virtual void logMessage(LogMessageType::Type type, const char *message);
+
void deinit();
virtual void getTimeAndDate(TimeDate &t) const;