mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-30 17:45:42 +00:00
GDScript Logger POC
This commit is contained in:
parent
951f49f665
commit
da5158ffde
|
@ -98,19 +98,49 @@ 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:
|
||||||
# Type of log messages:
|
var log_path: String = '/var/config/retrodeck/logs/gd_logs.log'
|
||||||
# log d - debug message: maybe in the future we can decide to hide them in main builds or if an option is toggled
|
var log_file: FileAccess = FileAccess.open(log_path, FileAccess.WRITE)
|
||||||
# log i - normal informational message
|
var log_line: String = "GD "
|
||||||
# log w - waring: something is not expected but it's not a big deal
|
match log_type:
|
||||||
# log e - error: something broke
|
'w':
|
||||||
var log_header_text = "gdc_"
|
log_line += "Warning "
|
||||||
log_header_text+=log_text
|
print("Warning, mate")
|
||||||
log_parameters = ["log", log_type, log_header_text]
|
'e':
|
||||||
log_result = await run_thread_command(wrapper_command,log_parameters, false)
|
log_line += "Error "
|
||||||
#log_result = await run_thread_command("find",["$HOME", "-name", "*.xml","-print"], false)
|
print("Error, mate")
|
||||||
#print (log_result["exit_code"])
|
'i':
|
||||||
#print (log_result["output"])
|
log_line += "Info "
|
||||||
|
print("Info, mate")
|
||||||
|
'd':
|
||||||
|
log_line += "Debug "
|
||||||
|
print("Debug, mate")
|
||||||
|
_:
|
||||||
|
print("No idea, mate")
|
||||||
|
log_line += log_text
|
||||||
|
print(log_line)
|
||||||
|
if log_file:
|
||||||
|
log_file.seek_end()
|
||||||
|
log_file.store_line(log_line)
|
||||||
|
log_file.close()
|
||||||
|
else:
|
||||||
|
print("Something wrong with log file")
|
||||||
|
|
||||||
|
# logger("e", "Could not open file: %s" % file_path)
|
||||||
|
|
||||||
func array_to_string(arr: Array) -> String:
|
func array_to_string(arr: Array) -> String:
|
||||||
var text: String
|
var text: String
|
||||||
|
|
Loading…
Reference in a new issue