Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 1.13 KB

ConsoleOutput.md

File metadata and controls

25 lines (19 loc) · 1.13 KB

Display output to the console

ConsoleService

The output to the Console should almout always use the ConsoleService to print output out to the console, this could be done in different ways.

Using the static service directly

Alt text

Using the Write helper methods in the CommandBase class

  • WriteCritical
  • WriteWarning
  • WriteError
  • WriteLine
  • and so on...

Why?

The output will be displayed in a decided way, warnings wil have a certain color, different from errors, and the output will be logged by default. And they will have log level corresponding to the type of output. WriteLine and Write have the options to be printed out to the console without being logged.

Exceptions

There are situations where Console.Write or WriteLine is useful, if you want to be sure that it will not be logged by mistake, the output of secrets for instance.

Read more about:

Design your Command

CommandBase the standard Command base class

Back to start