Init commit
This commit is contained in:
4
godot/scenes/utils/consts.gd
Normal file
4
godot/scenes/utils/consts.gd
Normal file
@ -0,0 +1,4 @@
|
||||
extends Resource
|
||||
|
||||
const DEFAULT_JUMP_VELOCITY: float = 4.5
|
||||
const DEFAULT_CHARACTER_SPEED: float = 5.0
|
50
godot/scenes/utils/logger.gd
Normal file
50
godot/scenes/utils/logger.gd
Normal file
@ -0,0 +1,50 @@
|
||||
extends Node
|
||||
class_name Logger
|
||||
|
||||
|
||||
var thread: Thread = Thread.new()
|
||||
var mutex: Mutex = Mutex.new()
|
||||
var log_queue: Array[String] = []
|
||||
var running: bool = true
|
||||
|
||||
|
||||
func _ready():
|
||||
thread.start(log_writer)
|
||||
|
||||
func info(msg: Variant):
|
||||
mutex.lock()
|
||||
log_queue.append("[color=white][b]INFO:[/b] [/color]" + msg)
|
||||
mutex.unlock()
|
||||
|
||||
func debug(msg: Variant):
|
||||
mutex.lock()
|
||||
log_queue.append("[color=cyan][b]DEBUG:[/b] [/color]" + msg)
|
||||
mutex.unlock()
|
||||
|
||||
func warning(msg: Variant):
|
||||
mutex.lock()
|
||||
log_queue.append("[color=yellow][b]WARN:[/b] [/color]" + msg)
|
||||
push_warning(msg)
|
||||
mutex.unlock()
|
||||
|
||||
|
||||
func error(msg: Variant):
|
||||
mutex.lock()
|
||||
log_queue.append("[color=red][b]ERROR:[/b] [/color]" + msg)
|
||||
push_error(msg)
|
||||
mutex.unlock()
|
||||
|
||||
func log_writer():
|
||||
while running:
|
||||
mutex.lock()
|
||||
while log_queue.size() > 0:
|
||||
var log_message = log_queue.pop_front()
|
||||
print_rich(log_message)
|
||||
mutex.unlock()
|
||||
|
||||
# Prevent high CPU usage
|
||||
await get_tree().create_timer(0.1).timeout
|
||||
|
||||
func _exit_tree():
|
||||
running = false
|
||||
thread.wait_to_finish()
|
Reference in New Issue
Block a user