Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a logger callback #126

Closed
lalop opened this issue Jun 2, 2013 · 13 comments
Closed

add a logger callback #126

lalop opened this issue Jun 2, 2013 · 13 comments

Comments

@lalop
Copy link
Contributor

lalop commented Jun 2, 2013

What do you of added a realtime logger ?

I think about something like that :

ORM::configure('logger', function($query){
...
});
@treffynnon
Copy link
Collaborator

I am not averse to this idea although I think it would be wise to make it suitable for PSR-3.

@treffynnon
Copy link
Collaborator

Do you have any further thoughts on this?

@lalop
Copy link
Contributor Author

lalop commented Jun 6, 2013

And do you mean by suitable for psr-3 ?
Make Idiorm a LoggerAwareInterface ?

Than log each request if log is enable ?

@treffynnon
Copy link
Collaborator

Yes, if it is possible whilst maintaining PHP 5.2 support.

@lalop
Copy link
Contributor Author

lalop commented Jun 7, 2013

If I'm wright that will add some dependencies to psr/log, isn't that a problem ?

@treffynnon
Copy link
Collaborator

I don't think so, but I have to admit I have not look properly. It should just allow a PSR-3 compliant logging library/class instance to be passed into Idiorm and Idiorm can then just call the appropriate methods without even using the Psr\Log namespace.

We don't need to enforce the interfaces if we don't want to as long as we are using the interfaces methods so if a PSR-3 logger is passed in it can be operated on reliably.

@lalop
Copy link
Contributor Author

lalop commented Jun 7, 2013

In fact whatever the logger object all we want is that it has a log method compliant with the LoggerInterface log method.
If we are ok I can add that.

@treffynnon
Copy link
Collaborator

Yep, that is what I was thinking. It's only slightly different to your suggested code as well.

@lalop
Copy link
Contributor Author

lalop commented Jun 7, 2013

so that's mean :

  • add a setLogger to ORM
  • add $logger->log('debug', $query, $parameters) in _log_query
  • format the query in the psr3 way

I'm not that is going in the idiorm design.

@treffynnon
Copy link
Collaborator

I'm not that is going in the idiorm design.

Sorry I do not understand this.

@lalop
Copy link
Contributor Author

lalop commented Jun 8, 2013

I forgot a word, sorry :
I'm not sure that is going in the idiorm design, beginning by the camelCase naming, then that add the logging functionality inside the library which one prone to be the most light possible.
I'm wondering if a simple callback isn't more in the spirit.

@treffynnon
Copy link
Collaborator

I see what you're saying. The call to any logger can just occur in the
callback. People could use memoization to maintain the same instance of
their logger across calls to the database maybe. In which this is a PSR3
compliant solution in my opinion.

@lalop lalop mentioned this issue Jun 10, 2013
@treffynnon
Copy link
Collaborator

Closing with preference to the pull request.

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

No branches or pull requests

2 participants