Hacker News new | ask | show | jobs
by preseinger 1092 days ago
if you pass a logger to a foo as a parameter to the foo constructor, then missing a logger is a compile-time error

if you pass a logger to a foo as a parameter in the request context, then missing a logger is a run-time error

1 comments

Fer sher. But a passed-by-Context logger could be used (for example) to override a library package's default (stdlib?) logger.

But what is the SOP / Best Practice here ? Do many libraries have some sort of SetLogger(..) initialization call, so that loggers don't clutter the API ? Or are error returns info-(over-)loaded ?

it's pretty straightforward, everything that logs takes a logger as a dependency during construction