/// <summary> /// 打印日志 /// </summary> /// <param name="socket">连接 服务器</param> /// <param name="loggerType">日志类型</param> /// <param name="message">信息</param> public static void Log(this RRPCServer socket, string message, LoggerType loggerType = LoggerType.Info) { message = "RRPPCServer " + message; Console.WriteLine(DateTime.Now + ":" + loggerType + ":" + message); var loginfo = new LoggerInfo() { LoggerType = loggerType, Message = message, Triggers = Triggers.Server }; LoggerList.Add(loginfo); LogFile(socket.Logger, loginfo); }
/// <summary> /// 写入到日志文件中 /// </summary> private static void LogFile(ILog log, LoggerInfo loggerInfo) { switch (loggerInfo.LoggerType) { case LoggerType.Error: log.Error(loggerInfo.Message); break; case LoggerType.Warning: log.Warn(loggerInfo.Message); break; case LoggerType.Info: log.Info(loggerInfo.Message); break; default: break; } }