You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.2 KiB
58 lines
1.2 KiB
#if !NET20
|
|
|
|
using System;
|
|
|
|
namespace Apewer.WebSocket
|
|
{
|
|
|
|
/// <summary></summary>
|
|
public enum LogLevel
|
|
{
|
|
|
|
/// <summary></summary>
|
|
Debug = 0,
|
|
|
|
/// <summary></summary>
|
|
Info = 1,
|
|
|
|
/// <summary></summary>
|
|
Warn = 2,
|
|
|
|
/// <summary></summary>
|
|
Error = 3
|
|
|
|
}
|
|
|
|
internal class WebSocketLog
|
|
{
|
|
public static LogLevel Level = LogLevel.Info;
|
|
|
|
public static Action<LogLevel, string, Exception> LogAction = (level, message, ex) =>
|
|
{
|
|
if (level >= Level) Console.WriteLine("{0} [{1}] {2} {3}", DateTime.Now, level, message, ex);
|
|
};
|
|
|
|
public static void Warn(string message, Exception ex = null)
|
|
{
|
|
LogAction(LogLevel.Warn, message, ex);
|
|
}
|
|
|
|
public static void Error(string message, Exception ex = null)
|
|
{
|
|
LogAction(LogLevel.Error, message, ex);
|
|
}
|
|
|
|
public static void Debug(string message, Exception ex = null)
|
|
{
|
|
LogAction(LogLevel.Debug, message, ex);
|
|
}
|
|
|
|
public static void Info(string message, Exception ex = null)
|
|
{
|
|
LogAction(LogLevel.Info, message, ex);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|