phase2 / rig

Outrigger command line tool
MIT License
11 stars 8 forks source link

[Project Config] Verbose logging not available in Commands() calls #88

Closed grayside closed 6 years ago

grayside commented 6 years ago

The logger is initialized on app.Before, which happens after commands are loaded and before the process of executing the selected command begins. As a result, cmd.Commands() is called for each command file before the verbose mode is activated. In fact, if any Command() function attempts to instantiate the logger it will keep logging non-verbose for the rest of the command execution because of the logger's singleton pattern.

After some consideration I do not see a way to change this. Commands() needs to be called as part of the cli bootstrap. Anything called from Commands() needs to carefully not use the Logger class.

This seems like something we need to settle and put into a nascent CONTRIBUTING.md

grayside commented 6 years ago

89 implements a bandaid for this by re-initializing the logger on command.Before. In that way whatever happens in Commands() is reset, and we just have a blanket policy of no Verbose logging in Commands().