Added hash map logging
authorpkanavos <pkanavos@gmail.com>
Sun, 25 Mar 2012 21:55:22 +0000 (00:55 +0300)
committerpkanavos <pkanavos@gmail.com>
Sun, 25 Mar 2012 21:55:22 +0000 (00:55 +0300)
trunk/Pithos.Network/CloudFilesClient.cs

index eb4e615..3601d62 100644 (file)
@@ -1069,9 +1069,22 @@ namespace Pithos.Network
                             //line by line
                             
                             var serializer = new JsonSerializer();                            
-                            var hashes=(List<string>)serializer.Deserialize(reader, typeof (List<string>));
-
-                            return hashes;
+                            serializer.Error += (sender, args) => Log.ErrorFormat("Deserialization error at [{0}] [{1}]", args.ErrorContext.Error, args.ErrorContext.Member);
+                            if (Log.IsDebugEnabled)
+                            {
+                                var body=reader.ReadToEnd();
+                                Log.DebugFormat("JSON response: {0}",body);
+                                using (var strReader = new StringReader(body))
+                                {
+                                    var hashes = (List<string>)serializer.Deserialize(strReader, typeof(List<string>));
+                                    return hashes;
+                                }
+                            }
+                            else
+                            {
+                                var hashes = (List<string>)serializer.Deserialize(reader, typeof(List<string>));
+                                return hashes;
+                            }
                         }                        
                     }                    
                     //Any other status code is unexpected and the exception should be rethrown