masonite icon indicating copy to clipboard operation
masonite copied to clipboard

Add `logging` feature with different logging handlers

Open circulon opened this issue 2 years ago • 5 comments

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 ?

  • [ ] Yes

Anything else ?

No response

circulon avatar Jun 07 '22 03:06 circulon

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).

girardinsamuel avatar Jun 07 '22 08:06 girardinsamuel

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

  • Python File (would use python logging module and just log to a file)
  • Rollbar or Sentry or some kind of third party logging solution

josephmancuso avatar Jun 07 '22 13:06 josephmancuso

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

josephmancuso avatar Jun 07 '22 13:06 josephmancuso

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

circulon avatar Jun 17 '22 03:06 circulon

I also need this feature. Hope it gets integrated.

goophps avatar Jun 18 '22 08:06 goophps