I finally published my first addon, and it hit the asset library today!

Log.pr(...) and Log.prn(...) are intended as drop-in replacements for print(...):

  • colorizes the output data based on type
  • recursively prints dictionaries and arrays
    • (with a sane max count, i.e. not printing 1000 entries in an array)
  • adds a script-name prefix and line-number before each log
    • with different treatment for [src:12]: vs <addons:12>: vs {test:12}: scripts

For me this helps reduce wall-of-text noise and eye strain while reading logs at a glance.

I created a docs site via docsify, and the code is on github.

I’ll be adding support for more types and customizing the color choices soon. You can opt-in to pretty-printing with your own objects by implementing a to_printable() function. I’m brainstorming ways to add support for not-your custom types as well (for example, Pandora Entities) - I have a few ideas but nothing implemented yet.

I’ve been using it in my own projects for a few months now, so it feels ready to share - I’m hopeful that others find it useful!

Try it out, let me know what you think!

  • russ@programming.devOP
    link
    fedilink
    English
    arrow-up
    4
    ·
    7 months ago

    Excellent! Let me know what you think or if you have any ideas - it’s easy to add more types, I’ve only been minimal so far. Vector3s come to mind…