Added an example to demonstrate how to use

Just to try and help folks wrap their heads around my project.
This commit is contained in:
david 2021-09-04 23:50:07 -04:00
parent f924628acc
commit 94bda86a8c
3 changed files with 40 additions and 0 deletions

3
.gitignore vendored
View File

@ -13,3 +13,6 @@ export_presets.cfg
.mono/
data_*/
mono_crash.*.json
# Exclude .log files
*.log

View File

@ -0,0 +1,21 @@
extends Node2D
# Obtain access to my plugin
onready var Log = $Logger
# Some example calls
func _ready():
# Standard calls with no secondary parameter
Log.debug("This is a debug statement")
Log.info("Information is ready")
Log.warn("Warning thrown") # Note: I could have also used Log.warning("Warning msg is same")
# More advanced calls with a second parameter (Decides to exit/end the progam
# This is calling error and setting it's auto_exit to false (it's default for errors)
Log.error("Failed obtaining acorns from squirrel army", false)
# This is calling critical (or crit) with it's default auto_exit setting (critical/crit will automatically exit)
Log.critical("This will auto exit after called", true) # Change to false to continue the program
printerr("This only goes to the console")
# Logger also includes some assistant functions
print("Current datetime stamp: ", Log.timestamp()) # This is used internally by Logger itself
print("Position of Example Logging node: ", Log.pos2str(self.position)) # This is so you can print positions

View File

@ -0,0 +1,16 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/Logger/log_base.gd" type="Script" id=1]
[ext_resource path="res://addons/Logger/example/Example Logging.gd" type="Script" id=2]
[node name="Example Logging" type="Node2D"]
position = Vector2( 250, 250 )
script = ExtResource( 2 )
[node name="Logger" type="Node" parent="."]
script = ExtResource( 1 )
__meta__ = {
"_editor_description_": "Logger V1.0 ApolloX"
}
persist_debug = false
file_dir = "res://addons/Logger/example/"