Invert coupling from Core to Logging

This commit is contained in:
Matt Nadareski
2024-07-17 16:01:22 -04:00
parent 5ca6da14fb
commit 0b84b85ba8
7 changed files with 45 additions and 36 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using SabreTools.Logging;
namespace SabreTools.Core.Tools
{
@@ -8,6 +9,23 @@ namespace SabreTools.Core.Tools
{
#region String to Enum
/// <summary>
/// Get the LogLevel value for an input string, if possible
/// </summary>
/// <param name="value">String value to parse/param>
/// <returns></returns>
public static LogLevel AsLogLevel(this string? value)
{
return value?.ToLowerInvariant() switch
{
"verbose" => LogLevel.VERBOSE,
"user" => LogLevel.USER,
"warning" => LogLevel.WARNING,
"error" => LogLevel.ERROR,
_ => LogLevel.VERBOSE,
};
}
/// <summary>
/// Get bool? value from input string
/// </summary>