Skip to content

Commit

Permalink
Merge pull request #9 from WildernessLabs/develop
Browse files Browse the repository at this point in the history
RC2
  • Loading branch information
jorgedevs authored Dec 31, 2022
2 parents e2cbedf + 66cb8bf commit d8ca1a8
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Source/Meadow.Logging/lib/ConsoleLogProvider.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,32 @@
namespace Meadow.Logging
using System;

namespace Meadow.Logging
{
/// <summary>
/// A Log Provider that outputs to the System Console
/// </summary>
public class ConsoleLogProvider : ILogProvider
{
/// <summary>
/// When true, the current log level will be prefixed to all logged messages
/// </summary>
public bool ShowLoglevel { get; set; } = false;

/// <summary>
/// Called when the associated Logger has a message call
/// </summary>
/// <param name="level">The LogLevel for the message</param>
/// <param name="message">The message to log</param>
public void Log(LogLevel level, string message)
{
System.Console.WriteLine($"{level.ToString().ToUpper()}: {message}");
if (ShowLoglevel)
{
Console.WriteLine($"{level.ToString().ToUpper()}: {message}");
}
else
{
Console.WriteLine($"{message}");
}
}
}
}

0 comments on commit d8ca1a8

Please sign in to comment.