From 6cb990cc2e9832b1ee327fa6ccfff23a6e7c016a Mon Sep 17 00:00:00 2001 From: Mathieu Bergounioux Date: Tue, 19 Apr 2022 16:13:27 +0200 Subject: [PATCH 1/2] fixed incorrect date formatting --- .../game/core-scripts/log/esc_logger.gd | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/addons/escoria-core/game/core-scripts/log/esc_logger.gd b/addons/escoria-core/game/core-scripts/log/esc_logger.gd index 064566c79..c2d22506a 100644 --- a/addons/escoria-core/game/core-scripts/log/esc_logger.gd +++ b/addons/escoria-core/game/core-scripts/log/esc_logger.gd @@ -262,10 +262,8 @@ func report_errors(p_path: String, errors: Array) -> void: # * message: Message to log # * err: if true, write in stderr func _log(message:String, err: bool = false): - var info = OS.get_datetime() - info["message"] = message - message = "{year}-{month}-{day}T{hour}{minute}{second} {message}" \ - .format(info) + message = "{0} {1}".format([_formatted_date(), message]) + if err: printerr(message) else: @@ -273,6 +271,20 @@ func _log(message:String, err: bool = false): _write_logfile(message) +# Returns the current date/time, as a string +# formatted for logging. E.g. 2022-04-19T16:10:39 +func _formatted_date() -> String: + var info = OS.get_datetime() + info["year"] = "%04d" % info["year"] + info["month"] = "%02d" % info["month"] + info["day"] = "%02d" % info["day"] + info["hour"] = "%02d" % info["hour"] + info["minute"] = "%02d" % info["minute"] + info["second"] = "%02d" % info["second"] + + return "{year}-{month}-{day}T{hour}:{minute}:{second}".format(info) + + # Returns the currently set log level # **Returns** Log level as set in the configuration func _get_log_level() -> int: From 6d26e0b8fbaad162d3fe5b6ec00911088f80d4b0 Mon Sep 17 00:00:00 2001 From: Mathieu Bergounioux Date: Tue, 19 Apr 2022 16:28:04 +0200 Subject: [PATCH 2/2] de-aligned assignments, as per PR review comment --- .../escoria-core/game/core-scripts/log/esc_logger.gd | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/addons/escoria-core/game/core-scripts/log/esc_logger.gd b/addons/escoria-core/game/core-scripts/log/esc_logger.gd index c2d22506a..195c3d3f6 100644 --- a/addons/escoria-core/game/core-scripts/log/esc_logger.gd +++ b/addons/escoria-core/game/core-scripts/log/esc_logger.gd @@ -275,12 +275,12 @@ func _log(message:String, err: bool = false): # formatted for logging. E.g. 2022-04-19T16:10:39 func _formatted_date() -> String: var info = OS.get_datetime() - info["year"] = "%04d" % info["year"] - info["month"] = "%02d" % info["month"] - info["day"] = "%02d" % info["day"] - info["hour"] = "%02d" % info["hour"] - info["minute"] = "%02d" % info["minute"] - info["second"] = "%02d" % info["second"] + info["year"] = "%04d" % info["year"] + info["month"] = "%02d" % info["month"] + info["day"] = "%02d" % info["day"] + info["hour"] = "%02d" % info["hour"] + info["minute"] = "%02d" % info["minute"] + info["second"] = "%02d" % info["second"] return "{year}-{month}-{day}T{hour}:{minute}:{second}".format(info)