tracy
tracy copied to clipboard
New StreamLogger & MultiLogger
- new feature: #281 #283 #280
- BC break: no
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).
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.
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.
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?
btw this is possibly relevant https://github.com/nette/tracy/pull/281/commits/62058e2b7fb89da25affd940b66ca5d6ab801855 from https://github.com/nette/tracy/pull/281
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?
The question is how to pass that the html filename from BlueScreenLogger to the other loggers when using a MultiLogger?
- 62058e2b7fb89da25affd940b66ca5d6ab801855 solves this by not having
BlueScreenLoggeras part ofMultiLogger - monolog-tracy-handler solves this by pre-computing the bluescreen filename before any logger is called and storing it in monolog LogRecord object.
None of those solution seem particularly elegant.