12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- using System.Threading;
- namespace Flyinsono.Client.Test
- {
- public class Logger
- {
- private static LogEngine _logEngine;
- private static string _accountName;
- public static bool Debug { get; set; }
- public static void RegisterEngine(LogEngine logEngine)
- {
- _logEngine = logEngine;
- }
- public static void WriteLineInfo(string msg)
- {
- _logEngine?.Write(LogLevel.Info, "[Thread:" + Thread.CurrentThread.ManagedThreadId.ToString() + "]" + msg);
- }
- public static void WriteLineWarn(string msg)
- {
- _logEngine?.Write(LogLevel.Warn, "[Thread:" + Thread.CurrentThread.ManagedThreadId.ToString() + "]" + msg);
- }
- public static void WriteLineError(string msg)
- {
- _logEngine?.Write(LogLevel.Error, "[Thread:" + Thread.CurrentThread.ManagedThreadId.ToString() + "]" + msg);
- }
- public static void WriteUserOperationLog(string msg, string accountName="")
- {
- if (string.IsNullOrEmpty(_accountName)&&!string.IsNullOrEmpty(accountName))
- {
- _accountName=accountName;
- }
- _logEngine?.Write(LogLevel.UserOperation, _accountName+":->"+msg);
- }
- public static void WriteLineVerbose(string msg)
- {
- #if DEBUG
- _logEngine?.Write(LogLevel.Verbose, "[Thread:" + Thread.CurrentThread.ManagedThreadId.ToString() + "]" + msg);
- #endif
- }
- public static void WriteLineDebug(string msg)
- {
- #if DEBUG
- _logEngine?.Write(LogLevel.Debug, "[Thread:" + Thread.CurrentThread.ManagedThreadId.ToString() + "]" + msg);
- #endif
- }
- }
- }
|