You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just couple thoughts about logger/helper. Want to hear your thoughts.
Logger extension
Logger interface could have WithCallerSkipCount method to return a new Logger (similar to Fields method). This way we could rebuild logger in NewHandler constructor with +1 skip.
DefaultLogger extension
It looks like common pattern of micro logger's usage is to call logger.Info / logger.Error, etc. So maybe interface type of DefaultLogger should also respect that and have Info/Error methods? I mean Helper-like interface. Or it can be of type Helper?
Helper + Logger
Do we need Helper apart from Logger actually? Wouldn't it be clearer to add methods from Helper to interface and implementations?
Eliminates Logger/Helper confusion.
Easier to add methods like WithCallerSkipCount (that return new Logger) to codebase - now you have to add it in Helper (to return new Helper) and in Logger (to return new Logger).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Just couple thoughts about logger/helper. Want to hear your thoughts.
Logger extension
Logger interface could have WithCallerSkipCount method to return a new Logger (similar to Fields method). This way we could rebuild logger in NewHandler constructor with +1 skip.
DefaultLogger extension
It looks like common pattern of micro logger's usage is to call logger.Info / logger.Error, etc. So maybe interface type of DefaultLogger should also respect that and have Info/Error methods? I mean Helper-like interface. Or it can be of type Helper?
Helper + Logger
Do we need Helper apart from Logger actually? Wouldn't it be clearer to add methods from Helper to interface and implementations?
Beta Was this translation helpful? Give feedback.
All reactions