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

fix: fixes incorrect date formatting #577

Merged
merged 2 commits into from
Apr 21, 2022
Merged
Changes from 1 commit
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
20 changes: 16 additions & 4 deletions addons/escoria-core/game/core-scripts/log/esc_logger.gd
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,29 @@ 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:
print(message)
_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"]
StraToN marked this conversation as resolved.
Show resolved Hide resolved
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:
Expand Down