Skip to content

Commit

Permalink
Config JSON: Only log notice for no custom JSON once (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
ithinkandicode authored Feb 28, 2023
1 parent e01a5d5 commit 01983b7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion addons/mod_loader/mod_loader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ var loaded_vanilla_parents_cache := {}
# Helps to decide whether a script extension should go through the _handle_script_extensions process
var is_initializing := true

# Keeps track of logged messages, to avoid flooding the log with duplicate notices
var logged_messages := []

# These variables handle various options, which can be changed via Godot's GUI
# by adding a ModLoaderOptions resource to the resource file specified by
# `ml_options_path`. See res://addons/mod_loader/options_examples for some
Expand Down Expand Up @@ -775,7 +778,11 @@ func get_mod_config(mod_dir_name: String = "", key: String = "") -> Dictionary:
if not status_code == MLConfigStatus.OK:
if status_code == MLConfigStatus.NO_JSON_OK:
# No user config file exists. Low importance as very likely to trigger
ModLoaderUtils.log_debug("Config JSON Notice: %s" % status_msg, mod_dir_name)
var full_msg = "Config JSON Notice: %s" % status_msg
# Only log this once, to avoid flooding the log
if not logged_messages.has(full_msg):
ModLoaderUtils.log_debug(full_msg, mod_dir_name)
logged_messages.push_back(full_msg)
else:
# Code error (eg. invalid mod ID)
ModLoaderUtils.log_fatal("Config JSON Error (%s): %s" % [status_code, status_msg], mod_dir_name)
Expand Down

0 comments on commit 01983b7

Please sign in to comment.