Don't truncate the log file

This commit is contained in:
WallK 2024-10-17 08:08:29 +03:00
parent 78b066ba8d
commit cb1316f7e1

View file

@ -98,41 +98,27 @@ func multi_state(section: String, state: String) -> String:
state = "mixed" state = "mixed"
return state return state
# func logger_bash(log_type: String, log_text: String) -> void:
# # Type of log messages:
# # log d - debug message: maybe in the future we can decide to hide them in main builds or if an option is toggled
# # log i - normal informational message
# # log w - waring: something is not expected but it's not a big deal
# # log e - error: something broke
# var log_header_text = "gdc_"
# log_header_text+=log_text
# log_parameters = ["log", log_type, log_header_text]
# log_result = await run_thread_command(wrapper_command,log_parameters, false)
# #log_result = await run_thread_command("find",["$HOME", "-name", "*.xml","-print"], false)
# #print (log_result["exit_code"])
# #print (log_result["output"])
func logger(log_type: String, log_text: String) -> void: func logger(log_type: String, log_text: String) -> void:
var log_dir_path: String = "/var/config/retrodeck/logs/" var log_dir_path: String = "/var/config/retrodeck/logs/"
var log_path: String = '/var/config/retrodeck/logs/gd_logs.log' var log_path: String = '/var/config/retrodeck/logs/gd_logs.log'
var log_dir: DirAccess = DirAccess.open(log_dir_path) var log_dir: DirAccess = DirAccess.open(log_dir_path)
var log_file: FileAccess = FileAccess.open(log_path, FileAccess.WRITE) var log_file: FileAccess = FileAccess.open(log_path, FileAccess.READ_WRITE)
var log_line: String = "GD " var log_line: String = "GD "
match log_type: match log_type:
'w': 'w':
log_line += "Warning " log_line += "Warning "
print("Warning, mate") # print("Warning, mate")
'e': 'e':
log_line += "Error " log_line += "Error "
print("Error, mate") # print("Error, mate")
'i': 'i':
log_line += "Info " log_line += "Info "
print("Info, mate") # print("Info, mate")
'd': 'd':
log_line += "Debug " log_line += "Debug "
print("Debug, mate") # print("Debug, mate")
_: _:
print("No idea, mate") print("No idea, mate")
log_line += log_text log_line += log_text