Skip to content

Commit

Permalink
fix: fixes incorrect date formatting (#577)
Browse files Browse the repository at this point in the history
* fixed incorrect date formatting

* de-aligned assignments, as per PR review comment

Co-authored-by: Mathieu Bergounioux <[email protected]>
  • Loading branch information
jeancallisti and Mathieu Bergounioux authored Apr 21, 2022
1 parent 1135b03 commit c4296a1
Showing 1 changed file with 16 additions and 4 deletions.
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"]
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

0 comments on commit c4296a1

Please sign in to comment.