diff options
author | Gone2Daly <71726742+Gone2Daly@users.noreply.github.com> | 2023-07-22 21:05:42 +0200 |
---|---|---|
committer | Gone2Daly <71726742+Gone2Daly@users.noreply.github.com> | 2023-07-22 21:05:42 +0200 |
commit | 71b3cd829f80de4c2cd3972d8bfd5ee470a5d180 (patch) | |
tree | b4280fde6eef2ae6987648bc7bf8e00e9011bb7f /game/addons/zylann.hterrain/util/logger.gd | |
parent | ce9022d0df74d6c33db3686622be2050d873ab0b (diff) |
init_testtest3d
Diffstat (limited to 'game/addons/zylann.hterrain/util/logger.gd')
-rw-r--r-- | game/addons/zylann.hterrain/util/logger.gd | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/game/addons/zylann.hterrain/util/logger.gd b/game/addons/zylann.hterrain/util/logger.gd new file mode 100644 index 0000000..fcc78a3 --- /dev/null +++ b/game/addons/zylann.hterrain/util/logger.gd @@ -0,0 +1,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) + |