tempestphp / tempest-framework

The PHP framework that gets out of your way 🌊
https://tempestphp.com
MIT License
804 stars 54 forks source link

Environment-specific logger channels #274

Open brendt opened 4 months ago

brendt commented 4 months ago

We need a way to define environment-specific logger channels.

My idea was to add an environments array to all channels, an add getEnvironments(): ?array on the interface.

return new LoggerConfig(
    channels: [
        new DailyLogChannel(
            path: 'path/to/log',
            environments: [Environment::PRODUCTION],
        ),
        new AppendLogChannel(
            path: 'path/to/log',
            environments: [Environment::DEV],
        ),
    ],
)
brendt commented 4 months ago

@przemyslaw-przylucki what do you think?

przemyslaw-przylucki commented 3 months ago

@brendt sorry - I was on a rather long business trip :/

I kinda like this approach but I feel like we could benefit more with env-specific config support like logger.production.php as we'll need more and more of that exentisivility.

Another cool thing would be to make initializers work like that too - it creates a bit more magic but also creates standards for how things are done. Not sure if I love it or not but it's an idea

brendt commented 2 months ago

I kinda like this approach but I feel like we could benefit more with env-specific config support like logger.production.php as we'll need more and more of that exentisivility.

Oh I think I like that! Let's have a discussion about it on discord as well