Description
Changelog
Reviews (0)

Picking the variant

Use the non-fatal version if you don't want to use fatal errors.

Use the fatal version if you want to use fatal errors, a fatal error is a level above Error and will cause the game to quit, but before quitting it will emit the FatalHandler.fatal signal :3.

How to use

These examples below have been tested in Godot and should work.

var SCRIPT_PATH := Log.get_script_path(self)

func _ready() -> void:
    const fname := "_ready"

    Log.trace("This is a trace message :3", SCRIPT_PATH, fname)
    Log.debug("Debugging ducks...", SCRIPT_PATH, fname)
    Log.info("Scene changed to 'res://test.tscn'", SCRIPT_PATH, fname)
    Log.warn("this thingy was wrong, so i corrected it from float to int", SCRIPT_PATH, fname)
    Log.error("file at path 'user://data.json' doesn't exist, falling back to default >:3", SCRIPT_PATH, fname)

    # if using the fatal variant:
    #Log.fatal("Something very wrong happened and can't fix it, quitting...", SCRIPT_PATH, fname)
    # 
    # you can also do this for a fatal or any log level:
    #Log.log("log message", SCRIPT_PATH,  Level.FATAL) # replace 'FATAL' with other log levels

Or if you want less writing:

func _ready() -> void:
    var s := Span.span(self, "_ready")

    s.trace("This is a trace message :3")
    s.debug("Debugging ducks...")
    s.info("Scene changed to 'res://test.tscn'")
    s.warn("this thingy was wrong, so i corrected it from float to int")
    s.error("file at path 'user://data.json' doesn't exist, falling back to default >:3")

    # if using the fatal variant:
    #s.fatal("Something very wrong happened and can't fix it, quitting...")
    # 
    # you can also do this for a fatal or any log level:
    #s.log("log message", Level.FATAL) # or other log levels

Example log output from examples above:

0:00:00:000:740856us TRACE res://main.gd:_ready:0 This is a trace message :3
0:00:00:000:740951us DEBUG res://main.gd:_ready:0 Debugging ducks...
0:00:00:000:741001us INFO  res://main.gd:_ready:0 Scene changed to 'res://test.tscn'
0:00:00:000:741049us WARN  res://main.gd:_ready:0 this thingy was wrong, so i corrected it from float to int
0:00:00:000:741174us ERROR res://main.gd:_ready:0 file at path 'user://data.json' doesn't exist, falling back to default >:3

Colored Godot output: Godot colored output

INFO ABOUT USING THE FATAL VERSION

If you use a MainLoop different than SceneTree you will probably need to change addons/nova_logger/quit_function_name to match the quit function of your main loop. If you don't know what a MainLoop is in Godot and use the normal Godot scenes and nodes you probably don't need to change this. :3

Other features

Easy script path getting:

  • Log.get_script_path(object) - gets the script path from the given object, if object has no path, then returns "<unknown>"

Max log level setting:

  • Log.set_max_log_level(Level.LEVEL) - setting this to Level.INFO will only make the logger print Info and above, used for changing the log level at runtime
  • addons/nova_logger/max_log_level - Setting for doing the above, but in ProjectSettings, recommended to use this as the base and changing using Log.set_max_log_level() on runtime (if needed)

Issues

If you find any issues, please report them on the source code repository with the needed minimal code to reproduce.

Changelog for version v0.2.0-non-fatal

No changelog provided for this version.

Reviews

NovaLogger has no reviews yet.

Login to write a review.

Consider supporting the creators!

If you enjoyed this asset consider supporting its creator. Follow the link below.