dojo / cli

:rocket: Dojo - command line tooling.
http://dojo.io
Other
26 stars 34 forks source link

Logging to console/stdout in a consistent fashion #140

Closed kitsonk closed 5 months ago

kitsonk commented 7 years ago

Enhancement

Related to #133

In order to have a consistent look and feel, we should have an abstraction API for logging to the console for CLI commands. The API should provide a set of semantic functions that allow for a consistent look and feel (but also make it easy to maintain, test, etc.).

For example, we could have something like:

interface CLILogger {
  commandStart(name: string, ...args: any[]): void;
  commandEnd(): void;
  action(name: string, ...args: any[]): void;
  processStart(name: string, ...args: any[]): void;
  processEnd(): void;
  verbose(message: string, ...args: any[]): void;
}

Also, in lots of places we log to console.log() but in some cases we have to write to stdout. I would say for CLI commands, we should generally manage writing to any WritableStream (but defaulting to process.stdout).