| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace NanoCLang { |
| | | 4 | | /// <summary> |
| | | 5 | | /// Provides the class to toggle the verbosity of the program output during well-formedness checking. |
| | | 6 | | /// </summary> |
| | | 7 | | public static class VerbConsole { |
| | | 8 | | /// <summary> |
| | | 9 | | /// Gets or sets the current verbosity level. All information that has less verbosity is omitted. |
| | | 10 | | /// </summary> |
| | 2176 | 11 | | public static VerbosityLevel Verbosity { get; set; } = VerbosityLevel.High; |
| | | 12 | | /// <summary> |
| | | 13 | | /// Writes a formatted string to the console depending on the current verbosity level. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <param name="level">Level of verbosity to print with. The higher the level of a write, the lower its importa |
| | | 16 | | /// <param name="format">A composite format string.</param> |
| | | 17 | | /// <param name="arg">An array of objects to write using <paramref name="format"/>.</param> |
| | 185 | 18 | | public static void WriteLine(VerbosityLevel level, string format, params object[] arg) { |
| | 185 | 19 | | if ((int)Verbosity <= (int)level) |
| | 0 | 20 | | Console.Error.WriteLine(format, arg); |
| | 185 | 21 | | } |
| | | 22 | | /// <summary> |
| | | 23 | | /// Writes a string to the console depending on the current verbosity level. |
| | | 24 | | /// </summary> |
| | | 25 | | /// <param name="level">Level of verbosity to print with. The higher the level of a write, the lower its importa |
| | | 26 | | /// <param name="value">The value to write.</param> |
| | 1990 | 27 | | public static void WriteLine(VerbosityLevel level, string value) { |
| | 1990 | 28 | | if ((int)Verbosity <= (int)level) |
| | 0 | 29 | | Console.Error.WriteLine(value); |
| | 1990 | 30 | | } |
| | | 31 | | } |
| | | 32 | | /// <summary> |
| | | 33 | | /// A verbosity level enumeration that lists possible verbosities. |
| | | 34 | | /// </summary> |
| | | 35 | | public enum VerbosityLevel : int { |
| | | 36 | | /// <summary> |
| | | 37 | | /// Low verbosity, only outputs on failure. |
| | | 38 | | /// </summary> |
| | | 39 | | Quiet = -5, |
| | | 40 | | /// <summary> |
| | | 41 | | /// Default verbosity, outputs important information. |
| | | 42 | | /// </summary> |
| | | 43 | | Default = 0, |
| | | 44 | | /// <summary> |
| | | 45 | | /// High verbosity, outputs additional information. |
| | | 46 | | /// </summary> |
| | | 47 | | High = 5 |
| | | 48 | | } |
| | | 49 | | } |