Skip to content
This repository has been archived by the owner on Feb 11, 2023. It is now read-only.

Monolog instance recreation check #3

Closed
wants to merge 1 commit into from
Closed

Monolog instance recreation check #3

wants to merge 1 commit into from

Conversation

jeroenbourgois
Copy link

If the monolog instance exists, and the _init function is called more than once,
any added handlers through pushHandler (thus inside $handlers array) are lost
because a new monolog instance is created. This check prevents that.

The fact that _init is called twice is something I do not fully understand. The reason I found this behaviour is because in a seperate custom package, I was calling \Log::instance()->pushHandler and when debugging I found that the _init was called. Both from my package as from inside fuel. The flow was:

  • request page/url
  • load fuel
  • load my custom package
  • initing the \Log instance from inside my custom package + add a Handler
  • the error is caught by Fuel and the \Log instance is created again -> my Handler is lost
  • only one error is logged to the file via the StreamHandler, but my custom handler is not called

I hope you can accept this fix or explain to me why it should behave like this - or how I should solve it in another way.

Thank you!

@pierot, @rob-bar, @jeroendp

… than once,

any added handlers through pushHandler (thus inside $handlers array) are lost
because a new monolog instance is created. This check prevents that
@WanWizard
Copy link
Member

This is a workaround for an issue elsewhere. I'd rather find that issue and fix that.

@WanWizard WanWizard closed this Feb 7, 2013
@jeroenbourgois
Copy link
Author

Ok :( I am willing to help find it, but I really need a fix :D It is cumbersome to change it manually in the package each time I start a new project (and error prone). Keep me posted please, and if I need to check something, feel free to ask.

@WanWizard
Copy link
Member

Lets keep this discussion here: #2

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants