Skip to content

Commit

Permalink
Even more logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
enyim committed Sep 10, 2010
1 parent 622470c commit 768fb59
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Enyim.Caching/Memcached/Protocol/Binary/DeleteOperation.cs
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Text;

namespace Enyim.Caching.Memcached.Protocol.Binary
{
public class DeleteOperation : BinarySingleItemOperation, IDeleteOperation
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(DeleteOperation));
public DeleteOperation(string key) : base(key) { }

protected override BinaryRequest Build()
Expand All @@ -23,6 +25,14 @@ protected internal override bool ReadResponse(PooledSocket socket)
var retval = response.Read(socket);
this.Cas = response.CAS;

#if EVEN_MORE_LOGGING
if (log.IsDebugEnabled)
if (retval)
log.DebugFormat("Delete succeeded for key '{0}'. Reason: {1}", this.Key);
else
log.DebugFormat("Delete failed for key '{0}'. Reason: {1}", this.Key, Encoding.ASCII.GetString(response.Data.Array, response.Data.Offset, response.Data.Count));
#endif

return retval;
}
}
Expand Down
12 changes: 12 additions & 0 deletions Enyim.Caching/Memcached/Protocol/Binary/GetOperation.cs
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using System.Text;

namespace Enyim.Caching.Memcached.Protocol.Binary
{
public class GetOperation : BinarySingleItemOperation, IGetOperation
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(GetOperation));
private CacheItem result;

public GetOperation(string key) : base(key) { }
Expand All @@ -29,11 +31,21 @@ protected internal override bool ReadResponse(PooledSocket socket)
this.result = new CacheItem((ushort)flags, response.Data);
this.Cas = response.CAS;

#if EVEN_MORE_LOGGING
if (log.IsDebugEnabled)
log.DebugFormat("Get succeeded for key '{0}'.", this.Key);
#endif

return true;
}

this.Cas = 0;

#if EVEN_MORE_LOGGING
if (log.IsDebugEnabled)
log.DebugFormat("Get failed for key '{0}'. Reason: {1}", this.Key, Encoding.ASCII.GetString(response.Data.Array, response.Data.Offset, response.Data.Count));
#endif

return false;
}

Expand Down
8 changes: 6 additions & 2 deletions Enyim.Caching/Memcached/Protocol/Binary/StoreOperation.cs
Expand Up @@ -52,9 +52,13 @@ protected internal override bool ReadResponse(PooledSocket socket)
var retval = response.Read(socket);
this.Cas = response.CAS;

if (!retval)
if (log.IsDebugEnabled)
#if EVEN_MORE_LOGGING
if (log.IsDebugEnabled)
if (retval)
log.DebugFormat("Store succeeded for key '{0}'. Reason: {1}", this.Key);
else
log.DebugFormat("Store failed for key '{0}'. Reason: {1}", this.Key, Encoding.ASCII.GetString(response.Data.Array, response.Data.Offset, response.Data.Count));
#endif

return retval;
}
Expand Down

0 comments on commit 768fb59

Please sign in to comment.