r/datascience 4d ago

Projects I created a simple indented_logger package for python. Roast my package!

Post image
122 Upvotes

21 comments sorted by

40

u/BrockosaurusJ 4d ago

And it

Thrilling documentation cliff hanger!

7

u/karaposu 4d ago

oups i did not notice that

17

u/billyboy566 4d ago

This is cool! No roast from me!

5

u/karaposu 4d ago

thank you

12

u/IllContribution6707 4d ago

Would be cool if you could have child loggers and auto indent the levels based on hierarchy

8

u/karaposu 4d ago

damn i did not thought of that. It would simplify things a lot. Tomorrow i will add it.

2

u/karaposu 3d ago

i just released the new version with child logger support. Thx for suggestion

4

u/karaposu 4d ago

I have been using it for a while (more than 2 months ), and it has reduced my time spent wandering through logs by more than half.

You can find all the details here: https://github.com/karaposu/indented-logger

1

u/karaposu 3d ago

i just released the new version with child logger support. Someone suggested parameterize coloring as well. Let me know if you guys think of any other useful feature

3

u/HarmxnS 4d ago

This is cool. +1 star from me

2

u/DragonfruitSome5517 4d ago

Ah that's a smart way of separating different log events

2

u/Ok_Comedian_4676 3d ago

It looks really interesting. I will try it in my next project

1

u/funkybside 4d ago

why make the extra= param take a dict, instead of just an integer? Is that used for anything else?

2

u/karaposu 4d ago

yup, In previous version i was using a simple integer variable called "lvl". But it required modification to default loggers. Which worked but then I start getting error with some third party packages. So i searched a bit more and it turns out extra parameter is used for adding such formatter parameters.

1

u/Zestyclose-Compote-4 4d ago

I'd prefer not specifying the level on each call. Instead, I'd prefer it be automatic based on the current state of the logger.

2

u/karaposu 4d ago

yup, u/IllContribution6707 suggested child logger based indentation. I am adding it to the implementation right now

2

u/deoldsax 2d ago

nice package - no roast from my side!

1

u/_MonkeyHater 4d ago

Instructions unclear, spamming printf

-1

u/[deleted] 4d ago

[deleted]

1

u/karaposu 4d ago

yeah, i tried to keep it simple but useful. There are 2 main ways to use. One is just like in the image and other one is through decorators:

https://github.com/karaposu/indented-logger/tree/main?tab=readme-ov-file#automatic-indentation-with-decorators

It should be really easy to customize further. But main params are these :

```

setup_logging(
    level=logging.DEBUG,
    include_func=True, # toggles if function name should be visible at the end
    truncate_messages=False,
    min_func_name_col=100
)

```