MasoniteFramework / masonite

The Modern And Developer Centric Python Web Framework. Be sure to read the documentation and join the Discord channel for questions: https://discord.gg/TwKeFahmPZ
http://docs.masoniteproject.com
MIT License
2.22k stars 126 forks source link

Add `logging` feature with different logging handlers #663

Closed circulon closed 5 months ago

circulon commented 2 years ago

Is your feature request related to a problem?

Kind of. Currently there is no way to log any form of message (exceptions, errors or debug info to persistent storage for later evaluation.

This is a problem in production scenarios where you want to store the message for evaluation and bug reproduction/confirmation.

What do we currently have to do now?

There is no easy out of the box way to do this.

Describe the solution you'd like

Possibly a LoggingProvider that can register handler/s Each handler listens for (or processes only) specific log level messages in a specific way

eg Each handler would receive the message as by the logging module (eg logging.info()). The handler would then process the message in whatever way is designed for. ie send to a file, add a row in a db table, custom handler to send to an external service via api, etc.

This offers maximum flexibility and configuration for logging messages of any type regardless of environment or deployment strategy.

Describe alternatives you've considered

Is there something I have missed with this?

Would this be a breaking change ?

Anything else ?

No response

girardinsamuel commented 2 years ago

There was a masonite-logging package in Masonite < 4. For Masonite 4 we have chosen to rely on the logging package directly.

However, having a LoggingProvider with different logging handlers - integrated into Masonite core - would be nice. This is a feature I was looking to add, but we did not put much priority on it for now, as we have planned some other features for Masonite 5 and the general ecosystem.

We will likely add this feature later, but for now we won't have time to implement it for Masonite 4 (I would be glad to help on this if you want to contribute to it).

josephmancuso commented 2 years ago

Yes I also support this feature. We can add a few different handlers as we had before:

josephmancuso commented 2 years ago

Can take a look at what masonite-logging had and replicate those features since that package was pretty complete for M3

circulon commented 2 years ago

Can take a look at what masonite-logging had and replicate those features since that package was pretty complete for M3

That Sounds great!. Thanks

In the mean time I have added a basic LoggingProvider to my M4 project to include a catchall and configuration based on the context the logging is working in (AWS Lambda or local development)

But yeah sounds like a great idea to reuse/tweak the M3 provider

goophps commented 2 years ago

I also need this feature. Hope it gets integrated.