Added a simple Logging system and enforced static typing in all files.
This commit is contained in:
parent
907b338c0e
commit
1607fe62cc
3 changed files with 91 additions and 0 deletions
39
scripts/utils/log.gd
Normal file
39
scripts/utils/log.gd
Normal file
|
@ -0,0 +1,39 @@
|
|||
extends Node
|
||||
|
||||
# This tells the game what the logmode is.
|
||||
# 0 -> None
|
||||
# 1 -> Errors
|
||||
# 2 -> Errors/Warnings
|
||||
# 3 -> Errors/Warnings/Infos
|
||||
# 4 -> All
|
||||
var logmode: int = 4
|
||||
|
||||
func _ready() -> void:
|
||||
debug("Test")
|
||||
info("Test")
|
||||
warning("Test")
|
||||
error("Test", "Test Message")
|
||||
|
||||
# Used for errors.
|
||||
func error(message: String, alert_message: String) -> void:
|
||||
if logmode >= 1:
|
||||
printerr("[ERROR] " + message)
|
||||
OS.alert(alert_message, "Error!")
|
||||
else:
|
||||
OS.alert("An error has occured. The program will now exit.", "Error!")
|
||||
get_tree().quit()
|
||||
|
||||
# Used for warnings.
|
||||
func warning(message: String) -> void:
|
||||
if logmode >= 2:
|
||||
printerr("[WARNING] " + message)
|
||||
|
||||
# Used for simple info.
|
||||
func info(message: String) -> void:
|
||||
if logmode >= 3:
|
||||
print("[INFO] " + message)
|
||||
|
||||
# Used for debugging.
|
||||
func debug(message: String) -> void:
|
||||
if logmode >= 4:
|
||||
print("[DEBUG] " + message)
|
Loading…
Add table
Add a link
Reference in a new issue