blob: fcc78a3e2cb39604c234cfafbf6e30af551b4e97 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
@tool
class HT_LoggerBase:
var _context := ""
func _init(p_context):
_context = p_context
func debug(msg: String):
pass
func warn(msg: String):
push_warning("{0}: {1}".format([_context, msg]))
func error(msg: String):
push_error("{0}: {1}".format([_context, msg]))
class HT_LoggerVerbose extends HT_LoggerBase:
func _init(p_context: String):
super(p_context)
func debug(msg: String):
print(_context, ": ", msg)
static func get_for(owner: Object) -> HT_LoggerBase:
# Note: don't store the owner. If it's a Reference, it could create a cycle
var script : Script = owner.get_script()
var context := script.resource_path.get_file()
if OS.is_stdout_verbose():
return HT_LoggerVerbose.new(context)
return HT_LoggerBase.new(context)
|