Skip to content

Commit

Permalink
Rename logfile to minetest.log by default, allow configuring logfile …
Browse files Browse the repository at this point in the history
…name

Also:
- Replace all hardcoded occurences of logfile name in the code with configured logfile name
- Report selected logfile to terminal on startup
- Add pattern minetest.log to .gitignore
  • Loading branch information
ClobberXD committed Jun 23, 2019
1 parent 429a989 commit c66c1bd
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Expand Up @@ -50,7 +50,7 @@ If you experience an issue, we would like to know the details - especially when
1. Do a quick search on GitHub to check if the issue has already been reported.
2. Is it an issue with the Minetest *engine*? If not, report it [elsewhere](http://www.minetest.net/development/#reporting-issues).
3. [Open an issue](https://github.com/minetest/minetest/issues/new) and describe the issue you are having - you could include:
- Error logs (check the bottom of the `debug.txt` file).
- Error logs (check the bottom of the logfile).
- Screenshots.
- Ways you have tried to solve the issue, and whether they worked or not.
- Your Minetest version and the content (games, mods or texture packs) you have installed.
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -54,6 +54,7 @@ gtags.files

## Configuration/log files
minetest.conf
minetest.log
debug.txt

## Other files generated by Minetest
Expand Down
6 changes: 4 additions & 2 deletions builtin/settingtypes.txt
Expand Up @@ -865,7 +865,7 @@ screenshot_quality (Screenshot quality) int 0 0 100
screen_dpi (DPI) int 72

# Windows systems only: Start Minetest with the command line window in the background.
# Contains the same information as the file debug.txt (default name).
# Contains the same information as the logfile.
enable_console (Enable console window) bool false

[Sound]
Expand Down Expand Up @@ -1277,8 +1277,10 @@ name (Player name) string
# A restart is required after changing this.
language (Language) enum ,be,ca,cs,da,de,dv,en,eo,es,et,fr,he,hu,id,it,ja,jbo,ko,ky,lt,ms,nb,nl,pl,pt,pt_BR,ro,ru,sl,sr_Cyrl,sv,sw,tr,uk,zh_CN,zh_TW

# Set name of logfile
logfile_name (Name of logfile) filepath minetest.log

# Level of logging to be written to debug.txt:
# Level of logging to be written to the logfile:
# - <nothing> (no logging)
# - none (messages with no level)
# - error
Expand Down
3 changes: 3 additions & 0 deletions minetest.conf.example
Expand Up @@ -1569,6 +1569,9 @@
# type: enum values: , be, ca, cs, da, de, dv, en, eo, es, et, fr, he, hu, id, it, ja, jbo, ko, ky, lt, ms, nb, nl, pl, pt, pt_BR, ro, ru, sl, sr_Cyrl, sv, sw, tr, uk, zh_CN, zh_TW
# language =

# Set name of logfile
logfile_name (Name of logfile) filepath minetest.log

# Level of logging to be written to debug.txt:
# - <nothing> (no logging)
# - none (messages with no level)
Expand Down
3 changes: 2 additions & 1 deletion src/client/game.cpp
Expand Up @@ -4255,7 +4255,8 @@ void the_game(bool *kill,
error_message = e.what();
errorstream << "ServerError: " << error_message << std::endl;
} catch (ModError &e) {
error_message = e.what() + strgettext("\nCheck debug.txt for details.");
std::string logfile_name = g_settings->get("logfile_name");
error_message = e.what() + strgettext("\nCheck " + logfile_name + " for details.");
errorstream << "ModError: " << error_message << std::endl;
}
}
1 change: 1 addition & 0 deletions src/defaultsettings.cpp
Expand Up @@ -32,6 +32,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("name", "");
settings->setDefault("bind_address", "");
settings->setDefault("serverlist_url", "servers.minetest.net");
settings->setDefault("logfile_name", "minetest.log")

// Client
settings->setDefault("address", "");
Expand Down
4 changes: 2 additions & 2 deletions src/emerge.cpp
Expand Up @@ -661,7 +661,7 @@ void *EmergeThread::run()
err << "World data version mismatch in MapBlock " << PP(pos) << std::endl
<< "----" << std::endl
<< "\"" << e.what() << "\"" << std::endl
<< "See debug.txt." << std::endl
<< "See " << g_settings->get("logfile_name") << std::endl
<< "World probably saved by a newer version of " PROJECT_NAME_C "."
<< std::endl;
m_server->setAsyncFatalError(err.str());
Expand All @@ -670,7 +670,7 @@ void *EmergeThread::run()
err << "Invalid data in MapBlock " << PP(pos) << std::endl
<< "----" << std::endl
<< "\"" << e.what() << "\"" << std::endl
<< "See debug.txt." << std::endl
<< "See " << g_settings->get("logfile_name") << std::endl
<< "You can ignore this using [ignore_world_load_errors = true]."
<< std::endl;
m_server->setAsyncFatalError(err.str());
Expand Down
2 changes: 1 addition & 1 deletion src/log.h
Expand Up @@ -33,7 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
class ILogOutput;

enum LogLevel {
LL_NONE, // Special level that is always printed
LL_NONE, // Special level that is always printed
LL_ERROR,
LL_WARNING,
LL_ACTION, // In-game actions
Expand Down
5 changes: 3 additions & 2 deletions src/main.cpp
Expand Up @@ -58,7 +58,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#error "Irrlicht 1.8.2 is known to be broken - please update Irrlicht to version >= 1.8.3"
#endif

#define DEBUGFILE "debug.txt"
#define DEFAULT_SERVER_PORT 30000

typedef std::map<std::string, ValueSpec> OptionList;
Expand Down Expand Up @@ -548,7 +547,9 @@ static bool read_config_file(const Settings &cmd_args)

static void init_log_streams(const Settings &cmd_args)
{
std::string log_filename = porting::path_user + DIR_DELIM + DEBUGFILE;
std::string logfile_name = g_settings->get("logfile_name");
std::string log_filename = porting::path_user + DIR_DELIM + logfile_name;
std::cout << "Logging to file: " << log_filename.c_str() << std::endl;

if (cmd_args.exists("logfile"))
log_filename = cmd_args.get("logfile");
Expand Down
4 changes: 2 additions & 2 deletions src/settings_translation_file.cpp
Expand Up @@ -420,7 +420,7 @@ fake_function() {
gettext("DPI");
gettext("Adjust dpi configuration to your screen (non X11/Android only) e.g. for 4k screens.");
gettext("Enable console window");
gettext("Windows systems only: Start Minetest with the command line window in the background.\nContains the same information as the file debug.txt (default name).");
gettext("Windows systems only: Start Minetest with the command line window in the background.\nContains the same information as the logfile.");
gettext("Sound");
gettext("Sound");
gettext("Volume");
Expand Down Expand Up @@ -637,7 +637,7 @@ fake_function() {
gettext("Language");
gettext("Set the language. Leave empty to use the system language.\nA restart is required after changing this.");
gettext("Debug log level");
gettext("Level of logging to be written to debug.txt:\n- <nothing> (no logging)\n- none (messages with no level)\n- error\n- warning\n- action\n- info\n- verbose");
gettext("Level of logging to be written to the logfile:\n- <nothing> (no logging)\n- none (messages with no level)\n- error\n- warning\n- action\n- info\n- verbose");
gettext("IPv6");
gettext("IPv6 support.");
gettext("Advanced");
Expand Down

0 comments on commit c66c1bd

Please sign in to comment.