ILog.cs 838 B

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.CommandLine;
  4. using System.CommandLine.Invocation;
  5. using System.CommandLine.IO;
  6. using System.CommandLine.Rendering;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace CustomHostingDemo
  11. {
  12. public interface ILog
  13. {
  14. void LogMessage(string msg);
  15. }
  16. public class Log : ILog
  17. {
  18. private readonly IConsole _console;
  19. public Log(InvocationContext context)
  20. {
  21. _console = context.Console;
  22. }
  23. public void LogMessage(string msg)
  24. {
  25. _console.Out.WriteLine(new ContainerSpan(
  26. ForegroundColorSpan.LightBlue(),
  27. new ContentSpan(msg),
  28. ForegroundColorSpan.Reset()
  29. ).ToString(OutputMode.Ansi));
  30. }
  31. }
  32. }