[Scummvm-git-logs] scummvm master -> 3c5d806894e5f8670e36c5050c04cbf3779eefd4

sev- sev at scummvm.org
Mon Aug 23 23:52:02 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
3c5d806894 3DS: Log all messages to a file


Commit: 3c5d806894e5f8670e36c5050c04cbf3779eefd4
    https://github.com/scummvm/scummvm/commit/3c5d806894e5f8670e36c5050c04cbf3779eefd4
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2021-08-24T01:51:59+02:00

Commit Message:
3DS: Log all messages to a file

Changed paths:
    backends/platform/3ds/osystem.cpp
    backends/platform/3ds/osystem.h


diff --git a/backends/platform/3ds/osystem.cpp b/backends/platform/3ds/osystem.cpp
index d7e3c6d405..8e40e53fef 100644
--- a/backends/platform/3ds/osystem.cpp
+++ b/backends/platform/3ds/osystem.cpp
@@ -84,7 +84,8 @@ OSystem_3DS::OSystem_3DS():
 	_screenChangeId(0),
 	_magnifyMode(MODE_MAGOFF),
 	exiting(false),
-	sleeping(false)
+	sleeping(false),
+	_logger(0)
 {
 	chdir("sdmc:/");
 
@@ -116,6 +117,9 @@ OSystem_3DS::~OSystem_3DS() {
 	destroyAudio();
 	destroy3DSGraphics();
 
+	delete _logger;
+	_logger = 0;
+
 	delete _timerManager;
 	_timerManager = 0;
 }
@@ -125,6 +129,15 @@ void OSystem_3DS::quit() {
 }
 
 void OSystem_3DS::initBackend() {
+	if (!_logger)
+		_logger = new Backends::Log::Log(this);
+
+	if (_logger) {
+		Common::WriteStream *logFile = createLogFile();
+		if (logFile)
+			_logger->open(logFile);
+	}
+
 	loadConfig();
 	ConfMan.registerDefault("fullscreen", true);
 	ConfMan.registerDefault("aspect_ratio", true);
@@ -157,6 +170,10 @@ Common::String OSystem_3DS::getDefaultConfigFileName() {
 	return "sdmc:/3ds/scummvm/scummvm.ini";
 }
 
+Common::String OSystem_3DS::getDefaultLogFileName() {
+	return "sdmc:/3ds/scummvm/scummvm.log";
+}
+
 void OSystem_3DS::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
 	s.add("RomFS", new Common::FSDirectory(DATA_PATH"/"), priority);
 }
@@ -222,6 +239,30 @@ void OSystem_3DS::fatalError() {
 
 void OSystem_3DS::logMessage(LogMessageType::Type type, const char *message) {
 	printf("%s", message);
+
+	// Then log into file (via the logger)
+	if (_logger)
+		_logger->print(message);
+}
+
+Common::WriteStream *OSystem_3DS::createLogFile() {
+	// Start out by resetting _logFilePath, so that in case
+	// of a failure, we know that no log file is open.
+	_logFilePath.clear();
+
+	Common::String logFile;
+	if (ConfMan.hasKey("logfile"))
+		logFile = ConfMan.get("logfile");
+	else
+		logFile = getDefaultLogFileName();
+	if (logFile.empty())
+		return nullptr;
+
+	Common::FSNode file(logFile);
+	Common::WriteStream *stream = file.createWriteStream();
+	if (stream)
+		_logFilePath = logFile;
+	return stream;
 }
 
 } // namespace N3DS
diff --git a/backends/platform/3ds/osystem.h b/backends/platform/3ds/osystem.h
index 991f342351..e3c92f6e7a 100644
--- a/backends/platform/3ds/osystem.h
+++ b/backends/platform/3ds/osystem.h
@@ -31,6 +31,7 @@
 #include "base/main.h"
 #include "audio/mixer_intern.h"
 #include "backends/graphics/graphics.h"
+#include "backends/log/log.h"
 #include "backends/platform/3ds/sprite.h"
 #include "common/rect.h"
 #include "common/queue.h"
@@ -201,8 +202,12 @@ private:
 	void flushGameScreen();
 	void flushCursor();
 
+	virtual Common::String getDefaultLogFileName();
+	virtual Common::WriteStream *createLogFile();
+
 protected:
 	Audio::MixerImpl *_mixer;
+	Backends::Log::Log *_logger;
 
 private:
 	u16 _gameWidth, _gameHeight;
@@ -287,6 +292,8 @@ private:
 	u16 _magWidth, _magHeight;
 	u16 _magCenterX, _magCenterY;
 
+	Common::String _logFilePath;
+
 public:
 	// Pause
 	PauseToken _sleepPauseToken;




More information about the Scummvm-git-logs mailing list