Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging: Use one shared logfile #3355

Merged
merged 7 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "font.h"
#include "cache.h"
#include "rtp.h"
#include "output.h"

#include <lcf/ldb/reader.h>
#include <lcf/reader_util.h>
Expand Down Expand Up @@ -182,6 +183,13 @@ std::string jstring_to_string(JNIEnv* env, jstring j_str) {
extern "C"
JNIEXPORT jobject JNICALL
Java_org_easyrpg_player_game_1browser_GameScanner_findGames(JNIEnv *env, jclass, jstring jpath, jstring jmain_dir_name) {
Output::SetLogLevel(LogLevel::Error);

auto sc = lcf::makeScopeGuard([&]() {
// Prevent closing of the stream, is used afterwards
Output::SetLogLevel(LogLevel::Debug);
});

EpAndroid::env = env;

// jpath is the SAF path to the game, is converted to FilesystemView "root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,20 @@ public static void launchGame(Context context, Game game, boolean debugMode) {
args.add(enc.getRegionCode());
}

String configPath = context.getExternalFilesDir(null).getAbsolutePath();
args.add("--config-path");
args.add(context.getExternalFilesDir(null).getAbsolutePath());
args.add(configPath);

String logFile;
if (game.isStandalone()) {
logFile = configPath + "/easyrpg-player.log";
} else {
// Placing the logfile directly in the EasyRPG directory gives a SecurityException
// Instead put it in the root of the savegame directory
logFile = SettingsManager.getSavesFolderURI(context) + "/easyrpg-player.log";
}
args.add("--log-file");
args.add(logFile);

/* FIXME: Currently disabled because the built-in scene cannot handle URI-encoded paths
// Sound Font Folder path (used by the settings scene)
Expand All @@ -105,6 +117,7 @@ public static void launchGame(Context context, Game game, boolean debugMode) {
}

intent.putExtra(EasyRpgPlayerActivity.TAG_SAVE_PATH, savePath);
intent.putExtra(EasyRpgPlayerActivity.TAG_LOG_FILE, logFile);
intent.putExtra(EasyRpgPlayerActivity.TAG_COMMAND_LINE, args.toArray(new String[0]));
intent.putExtra(EasyRpgPlayerActivity.TAG_STANDALONE, game.isStandalone());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package org.easyrpg.player.player;

import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.ClipDescription;
import android.content.Intent;
import android.content.res.AssetManager;
Expand Down Expand Up @@ -73,6 +74,7 @@
*/
public class EasyRpgPlayerActivity extends SDLActivity implements NavigationView.OnNavigationItemSelectedListener {
public static final String TAG_PROJECT_PATH = "project_path";
public static final String TAG_LOG_FILE = "log_file";
public static final String TAG_SAVE_PATH = "save_path";
public static final String TAG_COMMAND_LINE = "command_line";
public static final String TAG_STANDALONE = "standalone_mode";
Expand Down Expand Up @@ -239,13 +241,13 @@ private void reportBug() {
// set dialog message
alertDialogBuilder.setMessage(bug_msg).setCancelable(false)
.setPositiveButton(R.string.ok, (dialog, id) -> {
// Attach to the email : the easyrpg log file and savefiles
// Attach to the email: the easyrpg log file and savefiles
ArrayList<Uri> files = new ArrayList<>();

String savepath = getIntent().getStringExtra(TAG_SAVE_PATH);

if (getIntent().getBooleanExtra(TAG_STANDALONE, false)) {
File logFile = new File(savepath, "easyrpg_log.txt");
File logFile = new File(getIntent().getStringExtra(TAG_LOG_FILE));
if (logFile.exists()) {
Uri logUri = FileProvider.getUriForFile(this, getPackageName() + ".fileprovider", logFile);
if (logUri != null) {
Expand All @@ -263,11 +265,14 @@ private void reportBug() {
}
}
} else {
Uri saveFolder = Uri.parse(savepath);
Uri log = Helper.findFileUri(getContext(), saveFolder, "easyrpg_log.txt");
if (log != null) {
files.add(log);
// Must be properly URI encoded
SafFile logFile = SafFile.fromPath(getContext(), getIntent().getStringExtra(TAG_LOG_FILE));
if (logFile != null) {
files.add(logFile.getUri());
}

Uri saveFolder = Uri.parse(savepath);

// The save files
files.addAll(Helper.findFileUriWithRegex(getContext(), saveFolder, ".*lsd"));
}
Expand All @@ -289,8 +294,10 @@ private void reportBug() {
intent.putExtra(Intent.EXTRA_SUBJECT, "Bug report");
intent.putExtra(Intent.EXTRA_TEXT, getApplicationContext().getString(R.string.report_bug_mail));
intent.putExtra(Intent.EXTRA_STREAM, files);
if (intent.resolveActivity(getPackageManager()) != null) {
try {
startActivity(intent);
} catch (ActivityNotFoundException e) {
Log.e("EasyRPG", "No Mail App found");
}
}).setNegativeButton(R.string.cancel, (dialog, id) -> dialog.cancel());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public static SafFile fromPath(Context context, String path) {
return new SafFile(context, uri);
}

public Uri getUri() {
return rootUri;
}

public boolean isFile() {
populateMetadata();
return metaExists && metaIsFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,15 @@ public static Uri getGamesFolderURI(Context context) {
}
}

public static Uri getSavesFolderURI(Context context) {
DocumentFile easyRPGFolder = Helper.getFileFromURI(context, getEasyRPGFolderURI(context));
if (easyRPGFolder != null) {
return Helper.findFileUri(context, easyRPGFolder.getUri(), SAVES_FOLDER_NAME);
} else {
return null;
}
}

public static Uri getRTPFolderURI(Context context) {
DocumentFile easyRPGFolder = Helper.getFileFromURI(context, getEasyRPGFolderURI(context));
if (easyRPGFolder != null) {
Expand Down
46 changes: 25 additions & 21 deletions resources/unix/easyrpg-player.6.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ NOTE: For games that only use ASCII (English games) use '1252'.
selected font lacks certain glyphs the built-in pixel font is used.

*--font1-size* _PX_::
Size of font 1 in pixel. The default value is 12.
Size of font 1 in pixels. The default value is 12.

*--font2* _FILE_::
Path to a font to use for the second font. See font 1 for further information.

*--font2-size* _PX_::
Size of font 2 in pixel. The default value is 12.
Size of font 2 in pixels. The default value is 12.

*--font-path* _PATH_::
Configures the path where the settings scene looks for fonts. The user can
Expand All @@ -87,6 +87,10 @@ NOTE: For games that only use ASCII (English games) use '1252'.
*--load-game-id* _ID_::
Skip the title scene and load Save__ID__.lsd ('ID' is padded to two digits).

*--log-file* _FILE_::
Path to the logfile. The Player will write diagnostic messages to this file.
The default logfile is '$XDG_STATE_HOME/EasyRPG-Player.log'.

*--new-game*::
Skip the title scene and start a new game directly.

Expand All @@ -97,14 +101,14 @@ NOTE: For games that only use ASCII (English games) use '1252'.
Disable support for the Runtime Package (RTP). Will lead to checkerboard
graphics and silent music/sound effects in games depending on the RTP.

*--patch-antilag-switch*:: _SWITCH_
*--patch-antilag-switch* _SWITCH_::
Disables event page refreshing when the switch 'SWITCH' is set to 'ON'.

*--patch-common-this*::
Enable usage of __This Event__ in common events in any version of the engine.
By default, this behaviour is only enabled for RPG Maker 2003 v1.12.

*--patch-direct-menu*:: _VAR_
*--patch-direct-menu* _VAR_::
Directly access subscreens of the default menu by setting VAR.
See also: https://dev.makerpendium.de/docs/patch_db/main-en.htm?page=direct_menu

Expand All @@ -119,11 +123,11 @@ NOTE: For games that only use ASCII (English games) use '1252'.
*--patch-key-patch*::
Enable support for the Key Patch by Ineluki.

*--patch-maniac*:: _[N]_
*--patch-maniac* _[N]_::
Enable support for the Maniac Patch by BingShan.
Values for N:
- 1: Enable the patch (default)
- 2: Enable the patch but do not adjust variable ranges to 32 bit.
- 2: Enable the patch but do not adjust variable ranges to 32-bit.

Not adjusting the variable ranges is useful if you are adding the patch to an
existing game, as this reduces the likelihood that the game will stop working.
Expand All @@ -139,7 +143,7 @@ NOTE: For games that only use ASCII (English games) use '1252'.
Disable all engine patches.

NOTE: Providing any patch option disables the patch autodetection of the engine.
To disable a single patch, prefix any of the patch options with **--no-**.
To disable a single patch, prefix any of the patch options with *--no-*.

*--project-path* _PATH_::
Instead of using the working directory, the game in 'PATH' is used.
Expand All @@ -148,8 +152,8 @@ To disable a single patch, prefix any of the patch options with **--no-**.
Record all button inputs to 'FILE'.

*--replay-input* _FILE_::
Replays button input from 'FILE', as generated by **--record-input**. If the
RNG seed (**--seed**) and the state of the save file directory are the same as
Replays button input from 'FILE', as generated by *--record-input*. If the
RNG seed (*--seed*) and the state of the save file directory are the same as
it was when the log was recorded, this should reproduce an identical run to
the one recorded.

Expand All @@ -171,7 +175,7 @@ NOTE: When using the game browser all games will share the same save directory!

*--fps-limit*::
In combination with *--no-vsync* sets a custom frames per second limit. If
unspecified, the default is 60 fps. Set to 0 or use **--no-fps-limit** to
unspecified, the default is 60 fps. Set to 0 or use *--no-fps-limit* to
disable the frame limiter. This option may not be supported on all platforms.

*--fps-render-window*::
Expand Down Expand Up @@ -260,7 +264,7 @@ NOTE: When using the game browser all games will share the same save directory!

NOTE: Incompatible with *--load-game-id*.

*--start-position* _X' 'Y_::
*--start-position* _X_ _Y_::
Overwrite the party start position and move the party to position ('X', 'Y').

NOTE: Incompatible with *--load-game-id*.
Expand Down Expand Up @@ -326,7 +330,7 @@ to specify a soundfont on the command line.
== Files

=== EasyRPG.ini
Sets game specific settings to alter the engine behaviour. It follows a simple
Sets game-specific settings to alter the engine behaviour. It follows a simple
*Key*=_Value_ syntax in multiple sections.

Options in section 'Game':
Expand Down Expand Up @@ -378,8 +382,8 @@ CommonThisEvent=1
Maniac=1
----

NOTE: Values in the configuration file will overwrite auto detected ones,
however command line parameters will take precedence.
NOTE: Values in the configuration file will overwrite auto-detected ones,
however, command line parameters will take precedence.

=== RPG_RT.ini
The game configuration file. It follows a simple *Key*=_Value_ syntax in
Expand All @@ -398,8 +402,8 @@ Options in section 'RPG_RT':

*WinW*=_WIDTH_::

Set a custom screen width in pixel. Use this in combination with *WinH*. The
x and y coordinate are at the top-left corner. This behaviour can be
Set a custom screen width in pixels. Use this in combination with *WinH*. The
x and y coordinates are at the top-left corner. This behaviour can be
altered with *FakeResolution*.

*WinH*=_HEIGHT_::
Expand Down Expand Up @@ -428,10 +432,10 @@ WinH=480
Encoding=1252
----

'Encoding=1252' sets the correct encoding for most english games.
'Encoding=1252' sets the correct encoding for most English games.

NOTE: Values in the configuration file will overwrite auto detected ones,
however command line parameters will take precedence.
NOTE: Values in the configuration file will overwrite auto-detected ones,
however, command line parameters will take precedence.

== Reporting Bugs

Expand All @@ -441,7 +445,7 @@ https://github.com/EasyRPG/Player/issues

== Copyright / Authors

EasyRPG Player is Copyright (C) 2007-2023 the EasyRPG authors, see file
EasyRPG Player is Copyright (C) 2007-2025 the EasyRPG authors, see file
AUTHORS.md for details.

This program is free software; you can redistribute it and/or modify it under
Expand All @@ -453,7 +457,7 @@ See the file COPYING or http://gnu.org/licenses/gpl.html for details.

mkxp - An open source RGSS (Ruby Game Scripting System) interface
implementation that aims to support games created by "RPG Maker XP",
"RPG Maker VX" and "RPG Maker VX Ace"
"RPG Maker VX" and "RPG Maker VX Ace".

For additional information about EasyRPG software and related projects there
is a wiki: https://wiki.easyrpg.org
Loading
Loading