dotnet-core_mail-server/SMTPServer/Logging/Logging.cs

51 lines
1.2 KiB
C#
Raw Normal View History

2016-11-23 21:32:40 +00:00
using System;
namespace Logging
{
public class Logging
{
private static LoggingType[] _ActiveLoggingTypes { get; set; }
public enum LoggingType
{
TRACE,
ERROR,
DEBUG,
WARNING,
INFO,
ALL
}
private static void AddLogMessage(LoggingType messagetype, string message)
{
if(CheckLoggingType(messagetype)) PrintToConsole(messagetype, message);
}
private static bool CheckLoggingType(LoggingType lt){
if (_ActiveLoggingTypes.Length < 1) {
_ActiveLoggingTypes = new LoggingType[1];
_ActiveLoggingTypes[0] = LoggingType.ALL;
}
bool found = false;
foreach(LoggingType l in _ActiveLoggingTypes)
{
if (l == lt || l == LoggingType.ALL)
{
found = true;
break;
}
}
return found;
}
private static void PrintToConsole(LoggingType lt, string message)
{
Console.WriteLine("[" + lt.ToString() + "]" + message);
}
}
}