-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BMSPT-295] changed log for new Logger
- Loading branch information
1 parent
31d5e3b
commit e8a367a
Showing
8 changed files
with
114 additions
and
19 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
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
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
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 |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
|
||
namespace BcfToolkit; | ||
|
||
/// <summary> | ||
/// Provides logging for different levels of messages. | ||
/// </summary> | ||
public static class Log { | ||
/// <summary> | ||
/// Delegate for handling log messages. | ||
/// </summary> | ||
public delegate void LogHandler(string message); | ||
|
||
private static LogHandler? LogDebug { get; set; } | ||
private static LogHandler? LogInfo { get; set; } | ||
private static LogHandler? LogWarning { get; set; } | ||
private static LogHandler? LogError { get; set; } | ||
|
||
/// <summary> | ||
/// Configuring the handlers with custom logging functions. | ||
/// </summary> | ||
public static void Configure( | ||
LogHandler? debugHandler = null, | ||
LogHandler? infoHandler = null, | ||
LogHandler? warningHandler = null, | ||
LogHandler? errorHandler = null) { | ||
LogDebug = debugHandler; | ||
LogInfo = infoHandler; | ||
LogWarning = warningHandler; | ||
LogError = errorHandler; | ||
} | ||
|
||
/// <summary> | ||
/// Configuring the handlers with `Console.WriteLine`. | ||
/// </summary> | ||
public static void ConfigureDefault() { | ||
LogDebug = Console.WriteLine; | ||
LogInfo = Console.WriteLine; | ||
LogWarning = Console.WriteLine; | ||
LogError = Console.WriteLine; | ||
} | ||
|
||
/// <summary> | ||
/// Write a log event with the debug level. | ||
/// </summary> | ||
/// <param name="message">Message describing the event.</param> | ||
public static void Debug(string message) { | ||
LogDebug?.Invoke(message); | ||
} | ||
|
||
/// <summary> | ||
/// Write a log event with the information level. | ||
/// </summary> | ||
/// <param name="message">Message describing the event.</param> | ||
public static void Info(string message) { | ||
LogInfo?.Invoke(message); | ||
} | ||
|
||
/// <summary> | ||
/// Write a log event with the warning level. | ||
/// </summary> | ||
/// <param name="message">Message describing the event.</param> | ||
public static void Warning(string message) { | ||
LogWarning?.Invoke(message); | ||
} | ||
|
||
/// <summary> | ||
/// Write a log event with the error level. | ||
/// </summary> | ||
/// <param name="message">Message describing the event.</param> | ||
public static void Error(string message) { | ||
LogError?.Invoke(message); | ||
} | ||
} |
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
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
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
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