public static void Warn(object message) { switch (LogEngineType) { case LogEngineTypeEnum.DefaultLogger: DefaultLogger.Warn(message); break; case LogEngineTypeEnum.FlashLogger: FlashLogger.Warn(message); break; } }
public async Task Invoke(HttpContext context) { var ipAddress = context.Connection.RemoteIpAddress; string[] whiteListIPList = options.WhiteList; var isInwhiteListIPList = whiteListIPList .Where(a => IPAddress.Parse(a) .Equals(ipAddress)) .Any(); if (!isInwhiteListIPList) { DefaultLogger.Warn($"{ipAddress} is not an allowed IP Address!"); context.Response.StatusCode = (int)HttpStatusCode.Forbidden; return; } await _next.Invoke(context); }
/// <summary> /// 连接失败 , 如果重新连接成功你将不会收到这个通知 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void MuxerConnectionFailed(Object sender, ConnectionFailedEventArgs e) { _consoleLogger.Warn("重新连接:Endpoint failed: " + e.EndPoint + ", " + e.FailureType + (e.Exception == null ? "" : (", " + e.Exception.Message))); }
public void Warn_RandomString_Void() { // arrange. var test = new DefaultLogger(); // act. test.Warn("yay", this); // assert. Assert.IsNotNull(test); }