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

PSR-3 adapter #314

Merged
merged 1 commit into from Aug 27, 2018

Conversation

@JanTvrdik
Copy link
Contributor

commented Aug 27, 2018

@dg Would you accept PR with PSR-3 adapter? So it would be possible to use any PSR-3 compatible logger (e.g. Monolog) with Tracy, i.e. the following would be possible

$psrLogger = new Monolog\Logger(...);
$tracyLogger = new Tracy\Bridges\Psr\PsrLoggerAdapter($psrLogger);
Tracy\Debugger::setLogger($tracyLogger);

Or we could even apply the adapter automatically, so the following would be possible:

$psrLogger = new Monolog\Logger(...);
Tracy\Debugger::setLogger($psrLogger);
@JanTvrdik

This comment has been minimized.

Copy link
Contributor Author

commented Aug 27, 2018

@dg Related question – would you accept PR with TracyLoggerToPsrLoggerAdapter (i.e. the other way around)? The following would be possible

$tracyLogger = Tracy\Debugger::getLogger();
$psrLogger = new Tracy\Bridges\Psr\TracyLoggerToPsrLoggerAdapter($tracyLogger);

$monolog = new Monolog\Logger(...);
$monolog->pushHandler(new Monolog\Handler\SyslogHandler(...));
$monolog->pushHandler(new Monolog\Handler\PsrHandler($psrLogger));

// ...

$tracyLogger = new Tracy\Bridges\Psr\PsrLoggerToTracyLoggerAdapter($monolog);
Tracy\Debugger::setLogger($tracyLogger);
@JanTvrdik

This comment has been minimized.

Copy link
Contributor Author

commented Aug 27, 2018

Alternative is to put those adapters to https://github.com/contributte/psr3-logging cc @f3l1x

@f3l1x

This comment has been minimized.

Copy link
Member

commented Aug 27, 2018

We can put these adapters into https://github.com/contributte/psr3-logging, if it'll be not part of the Tracy.

@dg

This comment has been minimized.

Copy link
Member

commented Aug 27, 2018

Would you accept PR with PSR-3 adapter? So it would be possible to use any PSR-3 compatible logger (e.g. Monolog) with Tracy, i.e. the following would be possible

If it is really useful, surely. (I suppose otherwise you wouldn't want it.)

Or we could even apply the adapter automatically, so the following would be possible:

It looks nice, but it means that the code in src knows about the code in bridges.

would you accept PR with TracyLoggerToPsrLoggerAdapter (i.e. the other way around)? The following would be possible

Names TracyToPsrLoggerAdapter & PsrToTracyLoggerAdapter seems imho better.


Is it somehow related to #281 & #283 ?

@JanTvrdik

This comment has been minimized.

Copy link
Contributor Author

commented Aug 27, 2018

The issue has been converted to PR with implementation. The tests failed on Travis with and odd error

Return value of Tester\Runner\Job::getHeaders() must be of the type array, null returned

which looks like either Tester (cc @milo) or PHP bug.


Is it somehow related to #281 & #283 ?

Not directly, but indirectly, yes.

  • PsrToTracyLoggerAdapter makes it easy to use any third party PSR-3 logger with Tracy, therefore reducing the need for having StreamLogger in Tracy.
  • TracyToPsrLoggerAdapter makes it easy to use any Tracy\ILogger with any library that can log to PSR-3 logger. This makes splitting Tracy\Logger to multiple smaller Tracy\ILogger implementations even more valuable as it allows for example using Tracy\BlueScreenLogger as one of Monolog handlers.

@JanTvrdik JanTvrdik closed this Aug 27, 2018

@JanTvrdik JanTvrdik reopened this Aug 27, 2018

@JanTvrdik

This comment has been minimized.

Copy link
Contributor Author

commented Aug 27, 2018

I restarted the build on Travis by using close-reopen combo and the test now works.

@f3l1x

This comment has been minimized.

Copy link
Member

commented Aug 27, 2018

Cool. 🤗

@dg

This comment has been minimized.

Copy link
Member

commented Aug 27, 2018

Thanks, merged.

@dg dg merged commit 6b9675e into nette:master Aug 27, 2018

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.6%) to 73.417%
Details

@JanTvrdik JanTvrdik deleted the JanTvrdik:pr/psr branch Aug 27, 2018

dg added a commit that referenced this pull request Sep 24, 2018

dg added a commit that referenced this pull request Sep 24, 2018

dg added a commit that referenced this pull request Sep 30, 2018

dg added a commit that referenced this pull request Oct 5, 2018

dg added a commit that referenced this pull request Oct 24, 2018

dg added a commit that referenced this pull request Nov 2, 2018

dg added a commit that referenced this pull request Nov 5, 2018

dg added a commit that referenced this pull request Nov 5, 2018

dg added a commit that referenced this pull request Nov 5, 2018

@slischka

This comment has been minimized.

Copy link

commented Nov 16, 2018

When will be this released ?

@mabar

This comment has been minimized.

Copy link

commented Nov 16, 2018

Nette 3.0

dg added a commit that referenced this pull request Nov 23, 2018

dg added a commit that referenced this pull request Feb 5, 2019

dg added a commit that referenced this pull request Feb 5, 2019

dg added a commit that referenced this pull request Feb 5, 2019

dg added a commit that referenced this pull request Feb 5, 2019

dg added a commit that referenced this pull request Feb 10, 2019

dg added a commit that referenced this pull request Feb 11, 2019

dg added a commit that referenced this pull request Feb 11, 2019

dg added a commit that referenced this pull request Feb 12, 2019

dg added a commit that referenced this pull request Feb 14, 2019

dg added a commit that referenced this pull request Feb 15, 2019

dg added a commit that referenced this pull request Feb 15, 2019

dg added a commit that referenced this pull request Feb 15, 2019

dg added a commit that referenced this pull request Feb 17, 2019

dg added a commit that referenced this pull request Feb 17, 2019

dg added a commit that referenced this pull request Feb 17, 2019

dg added a commit that referenced this pull request Feb 17, 2019

dg added a commit that referenced this pull request Feb 17, 2019

dg added a commit that referenced this pull request Feb 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.