nette / tracy

😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.
https://tracy.nette.org
Other
1.75k stars 218 forks source link

New StreamLogger & MultiLogger #556

Open f3l1x opened 1 year ago

f3l1x commented 1 year ago

Ahoj. Zkusil jsem navazat na #281 a pripravil PR s 2 loggery dle komentare https://github.com/nette/tracy/issues/280#issuecomment-1446550503

Motivace: Mit moznost logovat na STDOUT v prostredi Docker a nebo i ciste v php -S localhost:8000 .. Zaroven mit moznost zaregistrovat vice loggeru zaroven. Aby slo logovat na STDOUT a mit treba i posilani logu do Sentry (tady a tady).

dg commented 1 year ago

Did you name the it as StreamLogger that it doesn't clash with FileLogger (when both logs to a file)? Because I want to put this modification in Tracy 3, there is no need to maintain compatibility and it's fine to modify FileLogger.

f3l1x commented 1 year ago

Well, if it's same for you log into file and to stdout/stdout then it can be FileLogger, but I can imagine separate classes FileLogger, StreamLogger, DummyLogger (do nothing), MultiLogger (iterate over all). It's up to you.

dg commented 1 year ago

I'm a complete idiot, I thought there is a FileLogger in Tracy 🤦‍♂️

Ok, so it would probably be a good idea to remove the current Logger completely and replace it with a MultiLogger containing FileLogger, MailLogger and maybe something else.

The hypotetic StreamLogger should probably have a stream in the constructor (resource), if it has a path to a file (string), it should be called FileLogger imho.

The question is how to incorporate the fact that an HTML file is generated and stored in directory. Should this be a task for the other logger?

JanTvrdik commented 1 year ago

btw this is possibly relevant https://github.com/nette/tracy/pull/281/commits/62058e2b7fb89da25affd940b66ca5d6ab801855 from https://github.com/nette/tracy/pull/281

dg commented 1 year ago

Yeah, BlueScreenLogger looks like another logger that should be there.

The question is how to pass that the html filename from BlueScreenLogger to the other loggers when using a MultiLogger?

JanTvrdik commented 1 year ago

The question is how to pass that the html filename from BlueScreenLogger to the other loggers when using a MultiLogger?

None of those solution seem particularly elegant.