microsoft/TypeAgent

Public

mirrored fromhttps://github.com/microsoft/TypeAgentAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/collate-todos-into-todo-md

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

dotnet/autoShell/Logging/ConsoleLogger.cs

50lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4using System;
5
6namespace autoShell.Logging;
7
8/// <summary>
9/// Logger that writes all messages to the diagnostics output.
10/// Errors (red), warnings (yellow), and info (cyan) are also displayed on the console.
11/// Debug messages are written to diagnostics output only.
12/// </summary>
13internal class ConsoleLogger : ILogger
14{
15 /// <inheritdoc/>
16 public void Error(Exception ex)
17 {
18 System.Diagnostics.Debug.WriteLine(ex);
19 ConsoleColor previousColor = Console.ForegroundColor;
20 Console.ForegroundColor = ConsoleColor.Red;
21 Console.WriteLine("Error: " + ex.Message);
22 Console.ForegroundColor = previousColor;
23 }
24
25 /// <inheritdoc/>
26 public void Warning(string message)
27 {
28 System.Diagnostics.Debug.WriteLine(message);
29 ConsoleColor previousColor = Console.ForegroundColor;
30 Console.ForegroundColor = ConsoleColor.Yellow;
31 Console.WriteLine("Warning: " + message);
32 Console.ForegroundColor = previousColor;
33 }
34
35 /// <inheritdoc/>
36 public void Info(string message)
37 {
38 System.Diagnostics.Debug.WriteLine(message);
39 ConsoleColor previousColor = Console.ForegroundColor;
40 Console.ForegroundColor = ConsoleColor.Cyan;
41 Console.WriteLine("Info: " + message);
42 Console.ForegroundColor = previousColor;
43 }
44
45 /// <inheritdoc/>
46 public void Debug(string message)
47 {
48 System.Diagnostics.Debug.WriteLine(message);
49 }
50}
51