Skip to content

crisosphinx/CrispyLog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CrispyLog

A Godot 4.x+ based logging tool that works for games and applications, alike. Tool is intended to create reeadable, traceable logs that help track-down common issues in your application while providing verbose logging features.

Developed and built in 4.4.1.

On Versioning of this plugin

#.#.#-a-#


Major.Minor.Bug-alpha_status-Documentation

Major is a significant revision change. Minor is a minor revision change / func update / etc. Bug is a bug fix. alpha_status is for alpha and beta builds. Will not be added if not either. Documentation is a documentation update.

Trello Document / Roadmap

CrispyLog Trello

How to Use this Plugin

!! Note, if the settings changed are annoying and you want to revert, de-enable and re-enable the plugin to restore settings to the original settings.

  • Download and place into this directory:
    • res://addons/ so it should look like res://addons/CrispyLog
  • Go to Project -> Project Settings -> Plugins
    • Enable the plugin by checking the On checkbox - it will look like below
    • On | CrispyLog | x.x.x | Jeff Miller
  • Go to General -> CrispyLog
    • Open Color Pairs Dictionary
    • If you don't like a particular color, you can change it here.
  • There are various booleans to help manage log flow.
    • Print the Stack
    • Print to Console
    • Write to Log
    • Use Iso Time
  • You can change the Default Log to which ever classification you might like.
  • You can change the Default File Log to which ever classification you might like.
    • Available Enums (Godot will sometimes format enumerators as integers):
      • 0 = None
      • 1 = Trace
      • 2 = Verbose
      • 3 = Debug
      • 4 = System
      • 5 = Info (Defaults to this)
      • 6 = Success
      • 7 = Warning
      • 8 = Error
      • 9 = Critical
      • 10 = Fatal
      • 11 = Assert
      • 12 = Network
      • 13 = Performance
  • Once installed you can call the following commands
    • Trace Level
      • p.t(message: Variant, obj: Object, file_name_only: bool)
      • p.trc(message: Variant, obj: Object, file_name_only: bool)
      • p.trace(message: Variant, obj: Object, file_name_only: bool)
    • Verbose Level
      • p.v(message: Variant, obj: Object, file_name_only: bool)
      • p.vrb(message: Variant, obj: Object, file_name_only: bool)
      • p.verbose(message: Variant, obj: Object, file_name_only: bool)
    • Debug Level
      • p.d(message: Variant, obj: Object, file_name_only: bool)
      • p.dbg(message: Variant, obj: Object, file_name_only: bool)
      • p.debug(message: Variant, obj: Object, file_name_only: bool)
    • System Level
      • p.s(message: Variant, obj: Object, file_name_only: bool)
      • p.sys(message: Variant, obj: Object, file_name_only: bool)
      • p.system(message: Variant, obj: Object, file_name_only: bool)
    • Info Level
      • p.i(message: Variant, obj: Object, file_name_only: bool)
      • p.log(message: Variant, obj: Object, file_name_only: bool)
      • p.info(message: Variant, obj: Object, file_name_only: bool)
    • Success Level
      • p.y(message: Variant, obj: Object, file_name_only: bool)
      • p.yes(message: Variant, obj: Object, file_name_only: bool)
      • p.success(message: Variant, obj: Object, file_name_only: bool)
    • Warning Level
      • p.w(message: Variant, obj: Object, file_name_only: bool)
      • p.wrn(message: Variant, obj: Object, file_name_only: bool)
      • p.warning(message: Variant, obj: Object, file_name_only: bool)
    • Error Level
      • p.e(message: Variant, obj: Object, file_name_only: bool)
      • p.err(message: Variant, obj: Object, file_name_only: bool)
      • p.error(message: Variant, obj: Object, file_name_only: bool)
    • Critical Level
      • p.c(message: Variant, obj: Object, file_name_only: bool)
      • p.crt(message: Variant, obj: Object, file_name_only: bool)
      • p.critical(message: Variant, obj: Object, file_name_only: bool)
    • Fatal Level
      • p.f(message: Variant, obj: Object, file_name_only: bool)
      • p.ftl(message: Variant, obj: Object, file_name_only: bool)
      • p.fatal(message: Variant, obj: Object, file_name_only: bool)
    • Assert Level
      • p.a(message: Variant, assertion: bool, obj: Object, file_name_only: bool)
      • p.asrt(message: Variant, assertion: bool, obj: Object, file_name_only: bool)
      • p.assrt(message: Variant, assertion: bool, obj: Object, file_name_only: bool)
    • Network Level
      • p.n(message: Variant, obj: Object, file_name_only: bool)
      • p.net(message: Variant, obj: Object, file_name_only: bool)
      • p.network(message: Variant, obj: Object, file_name_only: bool)
    • Performance Level
      • p.p(message: Variant, obj: Object, file_name_only: bool)
      • p.prf(message: Variant, obj: Object, file_name_only: bool)
      • p.performance(message: Variant, obj: Object, file_name_only: bool)

Example

## Script name is "do_stuff.gd"

extends Node

func _ready() -> void:
    p.i("Hello world!", self)
    
    # This will print out, in the console, something like the following:
    # INFO  [2025/12/04_00:55:10]   [NodeInScene | do_stuff: _ready]
    #       [String]            | Hello world!

    p.i(1, self)
    # This will print out, in the console, something like the following:
    # INFO  [2025/12/04_00:55:10]   [NodeInScene | do_stuff: _ready]
    #       [int]               | 1

    p.i(get_tree().get_first_node_in_group("player"), self)
    # This will print out, in the console, something like the following:
    # INFO  [2025/12/04_00:55:10]   [NodeInScene | do_stuff: _ready]
    #       [Object]            | Player:<Node3D#199928392>

Logs

Log files save in Documents directory, regardless of system.

  • Windows / Posix:
    • C:\Users\[UserName]\Documents\.logs\[appname]\[year]\[month]\[day]\[hour_minute_second].log
  • Mac / Linux / Unix:
    • ~/Documents/.logs/[appname]/[year]/[month]/[day]/[hour_minute_second].log

How the plugin works

For those who are more tech-saavy...

The plugin installs two globals:

  • sf for settings functionality
  • p for print

sf is used by all scripts in the plugin to attain the Log Level enumerator and Color Pair Dictionary keys and values. Any private functions or variables are underscored and are provided with callouts in the docstring to not be used directly.

Example:

static func _log_message(message: Variant,
                         level: sf.LoggingLevel = sf.LoggingLevel.INFO,
                         assertion: bool = true) -> void:
    # ...

This function is privatized. You CAN use it directly, but I highly recommend not as it will add more code to your project or potentially break currently placed functionality. If you want to use it directly, along with other functions or variables that are privatized in certain scripts, you can either create a global to reference the script or place it in the scene and reference that object.

For example, you could create an empty Node, assign the script, call the Node and then call the relative function or variable from another script when referencing that Node.

Example scene:

Scene
 |_Node       (named A)
    |_Script  (named log_message.gd) # contains function _log_message(message)
# From player.gd script
func _ready() -> void:
    A.LogMessage._log_message("hello world", sf.LoggingLevel.Debug, true)
    # Long winded and requires a lot of set up. 
    # Result displays in a seafoam color (default):
    # DEBUG	[2025/12/02/02:26:57]    [player: _ready]
    #       [String]            | hello world
    #
    # vs.
    #
    var date: String = "{year}/{month}/{day}/{hour}_{minute}_{second}".format(
        Time.get_datetime_dict_from_system(true)
    )
    print("DEBUG [%s] [%s] hello world" % [str(date), self.name])
    # Even longer-winded with special coloration. 
    # Result displays in a white-ish color:
    # DEBUG [2025/12/2/2_32_55] [player] hello world
    #
    # vs.
    #
    p.d("hello world")
    # Works without having to implement anything special.
    # Result displays in a seafoam color (default):
    # DEBUG	[2025/12/02/02:26:57]    [player: _ready]
    #       [String]            | hello world
    #
    p.d("hello world", self)
    # Works without having to implement anything special.
    # Result displays in a green color:
    # DEBUG	[2025/12/02/02:26:57]	[Player1 | player: _ready]
    #       [String]            | hello world
    #

About

A Godot 4.4.x+ based logging tool that works for games and applications, alike. Tool is intended to create reeadable, traceable logs that help track-down common issues in your application while provided verbose logging features.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors