Edit of asset "Log.gd, a gdscript pretty-printer" Accepted

Old/Current New/Edit
Title Log.gd, a gdscript pretty-printer Log.gd, a gdscript pretty-printer
Description Log.gd provides static functions for printing colorized output. These
are intended as drop-in replacements for `print(...)`.

- `Log.pr(...)` - pretty print args in one line
- `Log.prn(...)` - the same, but with newlines
- `Log.warn(...)` - pretty-print without newlines AND push a warning via `push_warning`
- `Log.err(...)` - pretty-print without newlines AND push a error via `push_error`

This is very useful while developing, because your printed output is much more readable.

Colorized output

The colorized output really shines when showing nested data structures (`Arrays` and `Dictionaries`), but it's also very useful for other gdscript primitives, like `Vectors`, `NodePaths`, and `StringNames`. Support for more types is easily added, feel free to create an issue!

Call-site prefixes

Log's print functions will prefix the output with the name of the script the log comes from, including the line number.

This call-site feature is really nice! Unfortunately it can only be used during development - it depends on `get_stack()`, which is not available in production builds or at `@tool` script time.

Opt-in via duck-typing

You can opt-in to pretty-printing in your classes by implementing `to_pretty()`, which Log will pickup via duck-typing.

```gdscript
class_name ExampleClass

func to_pretty():
return {val=12}

func _ready():_
Log.pr(self) # colorized `{"val": 12}`
```

Full docs here: https://russmatney.github.io/log.gd/#/
Log.gd provides static functions for printing colorized output. These
are intended as drop-in replacements for `print(...)`.

- `Log.pr(...)` - pretty print args in one line
- `Log.prn(...)` - the same, but with newlines
- `Log.warn(...)` - pretty-print without newlines AND push a warning via `push_warning`
- `Log.err(...)` - pretty-print without newlines AND push a error via `push_error`

This is very useful while developing, because your printed output is much more readable.

Colorized output

The colorized output really shines when showing nested data structures (`Arrays` and `Dictionaries`), but it's also very useful for other gdscript primitives, like `Vectors`, `NodePaths`, and `StringNames`. Support for more types is easily added, feel free to create an issue!

Call-site prefixes

Log's print functions will prefix the output with the name of the script the log comes from, including the line number.

This call-site feature is really nice! Unfortunately it can only be used during development - it depends on `get_stack()`, which is not available in production builds or at `@tool` script time.

Opt-in via duck-typing

You can opt-in to pretty-printing in your classes by implementing `to_printable()`, which Log will pickup via duck-typing.

```gdscript
class_name ExampleClass

func to_printable():
return {val=12}

func _ready():_
Log.pr(self) # colorized `{"val": 12}`
```

Full docs here: https://russmatney.github.io/log.gd/#/
Category Tools Tools
License MIT MIT
Repository Provider GitHub GitHub
Repository Url https://github.com/russmatney/log.gd https://github.com/russmatney/log.gd
Issues Url https://github.com/russmatney/log.gd/issues https://github.com/russmatney/log.gd/issues
Godot version Godot 4.1 Godot 4.2
Version String v0.0.6 v0.0.4
Download Commit 91bf5d7e7a32b4ae09d097273fccb87cd5e366dc c34c26064c24c0f14f785d87c53b311f302051e1
Download Url (Computed) https://github.com/russmatney/log.gd/archive/91bf5d7e7a32b4ae09d097273fccb87cd5e366dc.zip https://github.com/russmatney/log.gd/archive/c34c26064c24c0f14f785d87c53b311f302051e1.zip
Icon Url https://raw.githubusercontent.com/russmatney/log.gd/main/docs/assets/Log_logo_4x.png
https://raw.githubusercontent.com/russmatney/log.gd/main/docs/assets/Log_logo_4x.png
Preview Insert
Type image
Image/Video URL https://raw.githubusercontent.com/russmatney/log.gd/main/docs/assets/example_gd_impl.png
Thumbnail
Preview Insert
Type image
Image/Video URL https://raw.githubusercontent.com/russmatney/log.gd/main/docs/assets/example_gd_output.png
Thumbnail
Preview Insert
Type video
Image/Video URL https://www.youtube.com/watch?v=5yuEuA6S-Ws
Thumbnail