Fixed non-persistent logging, bump to 1.3

This renames persist_debug to persist_log and fixes it so the file is actually cleared when asked for non-persisting logging.
This commit is contained in:
Beanzilla 2022-05-11 15:04:57 -04:00 committed by GitHub
parent dfb7c7ae9c
commit 215871f57b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@ tool
extends Node extends Node
var log_file = null var log_file = null
export var persist_debug = true export var persist_log = true # If false the log file gets cleared automatically every startup
var logy = null var logy = null
export var file_dir = "res://" export var file_dir = "res://"
@ -20,16 +20,17 @@ export var CRIT = true
func _enter_tree(): func _enter_tree():
logy = self logy = self
editor_description = "Logger V1.2 ApolloX" editor_description = "Logger V1.3 ApolloX"
logy.editor_description = "Logger V1.2 ApolloX" logy.editor_description = "Logger V1.3 ApolloX"
logy.setup() logy.setup()
return logy return logy
func setup(): func setup():
log_file = File.new() log_file = File.new()
var dtnow = timestamp(file_name_time_format) var dtnow = timestamp(file_name_time_format)
if !log_file.file_exists(file_dir + file_name.format({"dt": dtnow})) or !persist_debug: if !log_file.file_exists(file_dir + file_name.format({"dt": dtnow})) or !persist_log:
log_file.open(file_dir + file_name.format({"dt": dtnow}), File.WRITE) log_file.open(file_dir + file_name.format({"dt": dtnow}), File.WRITE)
log_file.store_string("") # Fix issue where non-persistent would not reset properly
log_file.close() log_file.close()
log_file.open(file_dir + file_name.format({"dt": dtnow}), File.READ_WRITE) log_file.open(file_dir + file_name.format({"dt": dtnow}), File.READ_WRITE)
log_file.seek_end() log_file.seek_end()