@@ -9,22 +9,41 @@ const UPDATE_INTERVAL := 0.1
9
9
const ERROR_MSG_PREFIX := "USER ERROR: "
10
10
const WARNING_MSG_PREFIX := "USER WARNING: "
11
11
# Any logs with three spaces at the beginning will be ignored.
12
- const IGNORE_PREFIX := " "
12
+ const IGNORE_PREFIX := " "
13
+
14
+ var godot_log : FileAccess
15
+ var godot_log_path : String
13
16
14
- var godot_log :FileAccess
15
17
16
18
func _ready ():
17
- var file_logging_enabled = ProjectSettings .get ("debug/file_logging/enable_file_logging" ) or ProjectSettings .get ("debug/file_logging/enable_file_logging.pc" )
18
- if ! file_logging_enabled :
19
+ if not _is_log_enabled ():
19
20
push_warning ("You have to enable file logging in order to use engine log monitor!" )
20
21
return
21
-
22
- var log_path = ProjectSettings .get ("debug/file_logging/log_path" )
23
- godot_log = FileAccess .open (log_path , FileAccess .READ )
24
22
25
- create_tween ().set_loops (
26
- ).tween_callback (_read_data
27
- ).set_delay (UPDATE_INTERVAL )
23
+ godot_log_path = ProjectSettings .get ("debug/file_logging/log_path" )
24
+ if not FileAccess .file_exists (godot_log_path ):
25
+ push_warning ("Log file not fount by path " + godot_log_path )
26
+ return
27
+
28
+ _start_watching ()
29
+
30
+
31
+ func _start_watching () -> void :
32
+ godot_log = FileAccess .open (godot_log_path , FileAccess .READ )
33
+ create_tween ().set_loops ().tween_callback (_read_data ).set_delay (UPDATE_INTERVAL )
34
+
35
+
36
+ func _is_log_enabled () -> bool :
37
+
38
+ if ProjectSettings .get ("debug/file_logging/enable_file_logging" ):
39
+ return true
40
+
41
+ # this feels so weird and wrong
42
+ # what about other platforms?
43
+ if OS .has_feature ("pc" ) and ProjectSettings .get ("debug/file_logging/enable_file_logging.pc" ):
44
+ return true
45
+
46
+ return false
28
47
29
48
30
49
func _read_data ():
0 commit comments