From 1a56edd7c057ed2da4727d16a2d1781a080f453f Mon Sep 17 00:00:00 2001 From: dudu Date: Tue, 3 Sep 2019 11:28:57 +0800 Subject: [PATCH] Fix mistaken LogError --- Enyim.Caching/Enyim.Caching.csproj | 1 + Enyim.Caching/Memcached/MemcachedNode.cs | 25 +++++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Enyim.Caching/Enyim.Caching.csproj b/Enyim.Caching/Enyim.Caching.csproj index f38cc726..3fd67486 100755 --- a/Enyim.Caching/Enyim.Caching.csproj +++ b/Enyim.Caching/Enyim.Caching.csproj @@ -13,6 +13,7 @@ https://github.com/cnblogs/EnyimMemcachedCore true latest + 2.4.0-beta2 diff --git a/Enyim.Caching/Memcached/MemcachedNode.cs b/Enyim.Caching/Memcached/MemcachedNode.cs index d4c077af..da30730c 100755 --- a/Enyim.Caching/Memcached/MemcachedNode.cs +++ b/Enyim.Caching/Memcached/MemcachedNode.cs @@ -28,7 +28,7 @@ public class MemcachedNode : IMemcachedNode private bool isDisposed; - private readonly EndPoint endPoint; + private readonly EndPoint _endPoint; private readonly ISocketPoolConfiguration config; private InternalPoolImpl internalPoolImpl; private bool isInitialized = false; @@ -40,7 +40,8 @@ public MemcachedNode( ISocketPoolConfiguration socketPoolConfig, ILogger logger) { - this.endPoint = endpoint; + _endPoint = endpoint; + EndPointString = endpoint?.ToString().Replace("Unspecified/", string.Empty); this.config = socketPoolConfig; if (socketPoolConfig.ConnectionTimeout.TotalMilliseconds >= Int32.MaxValue) @@ -72,9 +73,11 @@ protected INodeFailurePolicy FailurePolicy /// public EndPoint EndPoint { - get { return this.endPoint; } + get { return _endPoint; } } + public string EndPointString { get; private set; } + /// /// Gets a value indicating whether the server is working or not. Returns a cached state. /// To get real-time information and update the cached state, use the method. @@ -771,7 +774,7 @@ protected internal virtual PooledSocket CreateSocket() { try { - var ps = new PooledSocket(this.endPoint, this.config.ConnectionTimeout, this.config.ReceiveTimeout, _logger); + var ps = new PooledSocket(_endPoint, this.config.ConnectionTimeout, this.config.ReceiveTimeout, _logger); ps.Connect(); return ps; } @@ -787,13 +790,13 @@ protected internal virtual async Task CreateSocketAsync() { try { - var ps = new PooledSocket(this.endPoint, this.config.ConnectionTimeout, this.config.ReceiveTimeout, _logger); + var ps = new PooledSocket(_endPoint, this.config.ConnectionTimeout, this.config.ReceiveTimeout, _logger); await ps.ConnectAsync(); return ps; } catch (Exception ex) { - var endPointStr = endPoint.ToString().Replace("Unspecified/", string.Empty); + var endPointStr = _endPoint.ToString().Replace("Unspecified/", string.Empty); _logger.LogError(ex, $"Failed to {nameof(CreateSocketAsync)} to {endPointStr}"); throw; } @@ -835,7 +838,7 @@ protected virtual IPooledSocketResult ExecuteOperation(IOperation op) } catch (IOException e) { - _logger.LogError(nameof(MemcachedNode), e); + _logger.LogError(e, $"Failed to ExecuteOperation on {EndPointString}"); result.Fail("Exception reading response", e); return result; @@ -887,14 +890,14 @@ protected virtual async Task ExecuteOperationAsync(IOperati } catch (IOException e) { - _logger.LogError(nameof(MemcachedNode), e); + _logger.LogError(e, $"IOException occurs when ExecuteOperationAsync({op}) on {EndPointString}"); result.Fail("IOException reading response", e); return result; } catch (SocketException e) { - _logger.LogError(nameof(MemcachedNode), e); + _logger.LogError(e, $"SocketException occurs when ExecuteOperationAsync({op}) on {EndPointString}"); result.Fail("SocketException reading response", e); return result; @@ -936,7 +939,7 @@ protected virtual async Task ExecuteOperationAsync(IOperation op, Action