Skip to content

Commit

Permalink
V1.5 (#15)
Browse files Browse the repository at this point in the history
* Update project version.

* Fix a mistake where the separator placeholder in LoggieMsg.prefix was not used correctly.

* fix: pad timestamp fields that need padding

* LoggieSettings is now a Resource instead of Node. Fixes a memory leak.

* Fix issue where enforced production settings only worked if you weren't using custom_settings.gd.

* New setting: enforce_optimal_settings_in_release_build.

* Update some function parameter names to avoid shadowing existing members.

* Update a message in test.gd to use Loggie instead of print_rich.

* Update test.gd to explicitly test out a color styled version of each type of message.

* New feature: Message Segmentation.

* Update some function parameter/varaible names to avoid shadowing existing members.

* Remove original_content and support for it.

* Add LoggieMsg.tab.

* Apply parameter name change to a couple more places where it needed to be done.

* Add LoggieEnums.MsgType.

* Add LoggieTools.get_terminal_ready_string.

* Clean up LoggieMsg.output wrappers, and fix issue with improperly formatted output passed to stuff like push_error, push_warning and print_debug.

* Update a print in test.gd.

* Add tests for each type of coloring of messages.

---------

Co-authored-by: dusk <[email protected]>
  • Loading branch information
Shiva-Shadowsong and yusdacra authored Dec 1, 2024
1 parent 820b74b commit 028d8db
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 137 deletions.
2 changes: 2 additions & 0 deletions addons/loggie/custom_settings.gd.example
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ func load():
self.log_level = LoggieEnums.LogLevel.INFO
self.show_loggie_specs = LoggieEnums.ShowLoggieSpecsMode.ESSENTIAL
self.show_system_specs = true
self.enforce_optimal_settings_in_release_build = true

self.output_message_domain = true
self.print_errors_to_console = true
self.print_warnings_to_console = true
Expand Down
41 changes: 21 additions & 20 deletions addons/loggie/loggie.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
extends Node

## Stores a string describing the current version of Loggie.
const VERSION : String = "v1.4"
const VERSION : String = "v1.5"

## Emitted any time Loggie attempts to log a message.
## Useful for capturing the messages that pass through Loggie.
Expand Down Expand Up @@ -44,18 +44,19 @@ func _init() -> void:
if _settings != null:
self.settings = _settings.new()
self.settings.load()
if is_in_production():
self.settings.terminal_mode = LoggieEnums.TerminalMode.PLAIN
self.settings.box_characters_mode = LoggieEnums.BoxCharactersMode.COMPATIBLE
else:
push_error("Loggie loaded neither a custom nor a default settings file. This will break the plugin. Make sure that a valid loggie_settings.gd is in the same directory where loggie.gd is.")
return

if self.settings.enforce_optimal_settings_in_release_build == true and is_in_production():
self.settings.terminal_mode = LoggieEnums.TerminalMode.PLAIN
self.settings.box_characters_mode = LoggieEnums.BoxCharactersMode.COMPATIBLE

# Already cache the name of the singleton found at loggie's script path.
class_names[self.get_script().resource_path] = LoggieSettings.loggie_singleton_name

# Prepopulate class data from ProjectSettings to avoid needing to read files.
if settings.derive_and_show_class_names == true and OS.has_feature("debug"):
if self.settings.derive_and_show_class_names == true and OS.has_feature("debug"):
for class_data: Dictionary in ProjectSettings.get_global_class_list():
class_names[class_data.path] = class_data.class

Expand All @@ -70,20 +71,20 @@ func _init() -> void:
if Engine.is_editor_hint():
return

if settings.show_loggie_specs != LoggieEnums.ShowLoggieSpecsMode.DISABLED:
if self.settings.show_loggie_specs != LoggieEnums.ShowLoggieSpecsMode.DISABLED:
msg("👀 Loggie {version} booted.".format({"version" : self.VERSION})).color(Color.ORANGE).header().nl().info()
var loggie_specs_msg = LoggieSystemSpecsMsg.new().use_logger(self)
loggie_specs_msg.add(msg("|\t Using Custom Settings File: ").bold(), !uses_original_settings_file).nl().add("|\t ").hseparator(35).nl()

match settings.show_loggie_specs:
match self.settings.show_loggie_specs:
LoggieEnums.ShowLoggieSpecsMode.ESSENTIAL:
loggie_specs_msg.embed_essential_logger_specs()
LoggieEnums.ShowLoggieSpecsMode.ADVANCED:
loggie_specs_msg.embed_advanced_logger_specs()

loggie_specs_msg.preprocessed(false).info()

if settings.show_system_specs:
if self.settings.show_system_specs:
var system_specs_msg = LoggieSystemSpecsMsg.new().use_logger(self)
system_specs_msg.embed_specs().preprocessed(false).info()

Expand Down Expand Up @@ -130,37 +131,37 @@ func is_domain_enabled(domain_name : String) -> bool:
## Creates a new [LoggieMsg] out of the given [param msg] and extra arguments (by converting them to strings and concatenating them to the msg).
## You may continue to modify the [LoggieMsg] with additional functions from that class, then when you are ready to output it, use methods like:
## [method LoggieMsg.info], [method LoggieMsg.warn], etc.
func msg(msg = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
var loggieMsg = LoggieMsg.new(msg, arg1, arg2, arg3, arg4, arg5)
func msg(message = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
var loggieMsg = LoggieMsg.new(message, arg1, arg2, arg3, arg4, arg5)
loggieMsg.use_logger(self)
return loggieMsg

## A shortcut method that instantly creates a [LoggieMsg] with the given arguments and outputs it at the info level.
## Can be used when you have no intention of customizing a LoggieMsg in any way using helper methods.
## For customization, use [method msg] instead.
func info(msg = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
return msg(msg, arg1, arg2, arg3, arg4, arg5).info()
func info(message = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
return msg(message, arg1, arg2, arg3, arg4, arg5).info()

## A shortcut method that instantly creates a [LoggieMsg] with the given arguments and outputs it at the warn level.
## Can be used when you have no intention of customizing a LoggieMsg in any way using helper methods.
## For customization, use [method msg] instead.
func warn(msg = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
return msg(msg, arg1, arg2, arg3, arg4, arg5).warn()
func warn(message = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
return msg(message, arg1, arg2, arg3, arg4, arg5).warn()

## A shortcut method that instantly creates a [LoggieMsg] with the given arguments and outputs it at the error level.
## Can be used when you have no intention of customizing a LoggieMsg in any way using helper methods.
## For customization, use [method msg] instead.
func error(msg = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
return msg(msg, arg1, arg2, arg3, arg4, arg5).error()
func error(message = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
return msg(message, arg1, arg2, arg3, arg4, arg5).error()

## A shortcut method that instantly creates a [LoggieMsg] with the given arguments and outputs it at the debug level.
## Can be used when you have no intention of customizing a LoggieMsg in any way using helper methods.
## For customization, use [method msg] instead.
func debug(msg = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
return msg(msg, arg1, arg2, arg3, arg4, arg5).debug()
func debug(message = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
return msg(message, arg1, arg2, arg3, arg4, arg5).debug()

## A shortcut method that instantly creates a [LoggieMsg] with the given arguments and outputs it at the notice level.
## Can be used when you have no intention of customizing a LoggieMsg in any way using helper methods.
## For customization, use [method msg] instead.
func notice(msg = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
return msg(msg, arg1, arg2, arg3, arg4, arg5).notice()
func notice(message = "", arg1 = null, arg2 = null, arg3 = null, arg4 = null, arg5 = null) -> LoggieMsg:
return msg(message, arg1, arg2, arg3, arg4, arg5).notice()
Loading

0 comments on commit 028d8db

Please sign in to comment.