fx icon indicating copy to clipboard operation
fx copied to clipboard

Provide a user-controlled logger to the container for foundation modules to consume.

Open twilly opened this issue 5 years ago • 1 comments

Fx applications may provide a fx.Printer with the fx.Logger option. Typical Fx applications include a logging module that provides something more powerful than a fx.Printer, such as a Zap logger. However, if this logging module has a dependency on other modules (eg Zap cores), then these lower level modules have no method available to them outside of log and fmt. These are not good substitutes as it sidesteps the application author's control of stdout and stderr (eg fx.NopLogger).

One solution is to provide the fx.Printer type to modules, but it has drawbacks (possible multiple logger choices, resolving type collision if an application also fx.Provides an fx.Printer, etc).

twilly avatar Jan 30 '20 21:01 twilly

The main reason for that is that the typical logger inside a typical application requires configuration to set itself up properly. Configuration loading is part of the lifecycle managed by Fx, thus chicken and egg between logger and config.

glibsm avatar Jan 31 '20 00:01 glibsm