tracy icon indicating copy to clipboard operation
tracy copied to clipboard

New StreamLogger & MultiLogger

Open f3l1x opened this issue 2 years ago • 6 comments

  • 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).

f3l1x avatar Mar 08 '23 21:03 f3l1x

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.

dg avatar Mar 19 '23 15:03 dg

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.

f3l1x avatar Mar 20 '23 18:03 f3l1x

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?

dg avatar Mar 20 '23 18:03 dg

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

JanTvrdik avatar Mar 20 '23 19:03 JanTvrdik

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?

dg avatar Mar 20 '23 19:03 dg

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.

JanTvrdik avatar Mar 20 '23 19:03 JanTvrdik