-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from WildernessLabs/develop
RC2
- Loading branch information
Showing
1 changed file
with
16 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}"); | ||
} | ||
} | ||
} | ||
} |