Ticket #9260: log.patch
File log.patch, 5.5 KB (added by , 14 years ago) |
---|
-
new file ackends/log/log.cpp
diff --git a/backends/log/log.cpp b/backends/log/log.cpp new file mode 100644 index 0000000..dc7145c
- + 1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * $URL$ 22 * $Id$ 23 * 24 */ 25 26 #include "backends/log/log.h" 27 28 #include "common/stream.h" 29 #include "common/str.h" 30 #include "common/system.h" 31 32 #include "base/version.h" 33 34 namespace Backends { 35 namespace Log { 36 37 Log::Log(OSystem *system) : _system(system), _stream(0) { 38 assert(system); 39 } 40 41 void Log::open(Common::WriteStream *stream) { 42 close(); 43 44 _stream = stream; 45 print(gScummVMFullVersion); 46 print("\n", false); 47 print("--- Log opened.\n"); 48 } 49 50 void Log::close() { 51 if (_stream) { 52 print("--- Log closed successfully.\n"); 53 54 delete _stream; 55 _stream = 0; 56 } 57 } 58 59 void Log::print(const char *message, const bool printTime) { 60 if (!_stream) 61 return; 62 63 if (printTime) { 64 const uint32 time = _system->getMillis(); 65 _stream->writeString(Common::String::format("[%10d] ", time)); 66 } 67 68 _stream->write(message, strlen(message)); 69 _stream->flush(); 70 } 71 72 } // End of namespace Log 73 } // End of namespace Backends 74 -
new file ackends/log/log.h
diff --git a/backends/log/log.h b/backends/log/log.h new file mode 100644 index 0000000..ef9f9a2
- + 1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 * $URL$ 22 * $Id$ 23 * 24 */ 25 26 #ifndef BACKENDS_LOG_LOG_H 27 #define BACKENDS_LOG_LOG_H 28 29 #include "common/scummsys.h" 30 31 class OSystem; 32 33 namespace Common { 34 class WriteStream; 35 } // End of namespace Common 36 37 namespace Backends { 38 namespace Log { 39 40 class Log { 41 public: 42 Log(OSystem *system); 43 ~Log() { close(); } 44 45 void open(Common::WriteStream *stream); 46 void close(); 47 48 void print(const char *message, const bool printTime = true); 49 private: 50 OSystem *_system; 51 Common::WriteStream *_stream; 52 }; 53 54 } // End of namespace Log 55 } // End of namespace Backends 56 57 #endif 58 -
backends/module.mk
diff --git a/backends/module.mk b/backends/module.mk index db03e80..fab0751 100644
a b MODULE_OBJS := \ 15 15 keymapper/keymap.o \ 16 16 keymapper/keymapper.o \ 17 17 keymapper/remap-dialog.o \ 18 log/log.o \ 18 19 midi/alsa.o \ 19 20 midi/camd.o \ 20 21 midi/coreaudio.o \ -
backends/platform/sdl/sdl.cpp
diff --git a/backends/platform/sdl/sdl.cpp b/backends/platform/sdl/sdl.cpp index 8a139e5..589c553 100644
a b void OSystem_SDL::initBackend() { 182 182 error("Could not initialize SDL: %s", SDL_GetError()); 183 183 } 184 184 185 _logger = new Backends::Log::Log(this); 186 assert(_logger); 187 _logger->open(Common::FSNode("~/scummvm-log").createWriteStream()); 188 185 189 _graphicsMutex = createMutex(); 186 190 187 191 SDL_ShowCursor(SDL_DISABLE); … … OSystem_SDL::OSystem_SDL() 304 308 memset(&_mouseCurState, 0, sizeof(_mouseCurState)); 305 309 306 310 _inited = false; 307 311 _logger = 0; 308 312 309 313 #if defined(__amigaos4__) 310 314 _fsFactory = new AmigaOSFilesystemFactory(); … … void OSystem_SDL::deinit() { 545 549 free(_mouseData); 546 550 547 551 delete _timer; 552 delete _logger; 548 553 549 554 SDL_Quit(); 550 555 … … void OSystem_SDL::quit() { 564 569 565 570 void OSystem_SDL::logMessage(LogMessageType::Type type, const char *message) { 566 571 BaseBackend::logMessage(type, message); 572 if (_logger) 573 _logger->print(message); 567 574 568 575 #if defined( USE_WINDBG ) 569 576 #if defined( _WIN32_WCE ) -
backends/platform/sdl/sdl.h
diff --git a/backends/platform/sdl/sdl.h b/backends/platform/sdl/sdl.h index 328bb03..660ad07 100644
a b 33 33 #endif 34 34 35 35 #include "backends/base-backend.h" 36 #include "backends/log/log.h" 36 37 #include "graphics/scaler.h" 37 38 38 39 … … public: 243 244 244 245 protected: 245 246 bool _inited; 247 248 // Logging 249 Backends::Log::Log *_logger; 250 246 251 SDL_AudioSpec _obtainedRate; 247 252 248 253 #ifdef USE_OSD