mirror of
https://github.com/RetroDECK/RetroDECK.git
synced 2024-11-28 00:25:42 +00:00
Try to create log folder
This commit is contained in:
parent
da5158ffde
commit
78b066ba8d
|
@ -113,8 +113,12 @@ func multi_state(section: String, state: String) -> String:
|
||||||
# #print (log_result["output"])
|
# #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_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_file: FileAccess = FileAccess.open(log_path, FileAccess.WRITE)
|
var log_file: FileAccess = FileAccess.open(log_path, FileAccess.WRITE)
|
||||||
|
|
||||||
var log_line: String = "GD "
|
var log_line: String = "GD "
|
||||||
match log_type:
|
match log_type:
|
||||||
'w':
|
'w':
|
||||||
|
@ -133,6 +137,13 @@ func logger(log_type: String, log_text: String) -> void:
|
||||||
print("No idea, mate")
|
print("No idea, mate")
|
||||||
log_line += log_text
|
log_line += log_text
|
||||||
print(log_line)
|
print(log_line)
|
||||||
|
|
||||||
|
if not log_dir:
|
||||||
|
log_dir = DirAccess.open("res://") #open something valid to create an instance
|
||||||
|
if log_dir.make_dir_recursive(log_dir_path) != OK:
|
||||||
|
print("Something wrong with log directory")
|
||||||
|
return
|
||||||
|
|
||||||
if log_file:
|
if log_file:
|
||||||
log_file.seek_end()
|
log_file.seek_end()
|
||||||
log_file.store_line(log_line)
|
log_file.store_line(log_line)
|
||||||
|
@ -140,8 +151,6 @@ func logger(log_type: String, log_text: String) -> void:
|
||||||
else:
|
else:
|
||||||
print("Something wrong with log file")
|
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
|
||||||
for line in arr:
|
for line in arr:
|
||||||
|
|
Loading…
Reference in a new issue