From: Jon Trowbridge <trow@novell.com>

Use beagle's logger to debug locking

--- Lucene.Net.Orig/Store/FSDirectory.cs	2005-10-03 21:08:36.000000000 +0100
+++ Lucene.Net/Store/FSDirectory.cs	2005-10-03 21:10:00.000000000 +0100
@@ -72,22 +72,26 @@ namespace Lucene.Net.Store
 					}
 				}
 
-				if (System.IO.File.Exists(lockFile.FullName))
-					return false;
+				bool obtainedLock = false;
 
-                try
-                {
-                    System.IO.FileStream createdFile = lockFile.Create();
-					System.IO.StreamWriter writer = new System.IO.StreamWriter (createdFile);
-					writer.WriteLine (System.Diagnostics.Process.GetCurrentProcess().Id);
-					writer.Close ();
-                    createdFile.Close();
-                    return true;
-                }
-                catch (Exception)
-                {
-                    return false;
-                }
+				if (! System.IO.File.Exists(lockFile.FullName)) {
+                	try
+	                {
+    	                System.IO.FileStream createdFile = lockFile.Create();
+						System.IO.StreamWriter writer = new System.IO.StreamWriter (createdFile);
+						writer.WriteLine (System.Diagnostics.Process.GetCurrentProcess().Id);
+						writer.Close ();
+                    	createdFile.Close();
+	                    obtainedLock = true;
+    	            }
+        	        catch (Exception)
+            	    {
+                	    // Fall through
+	                }
+				}
+
+				Log ("{0} lock {1}", obtainedLock ? "Obtained" : "Could not obtain", lockFile.FullName);
+				return obtainedLock;
 			}
 			public override void  Release()
 			{
@@ -107,6 +111,10 @@ namespace Lucene.Net.Store
 				else
 					tmpBool = false;
 				bool generatedAux = tmpBool;
+				if (tmpBool)
+					Log ("Released lock {0}", lockFile.FullName);
+				else
+					Log ("Failed to release lock {0}", lockFile.FullName);
 			}
 			public override bool IsLocked()
 			{
@@ -577,6 +585,20 @@ namespace Lucene.Net.Store
         {
             return new FSIndexInput(new System.IO.FileInfo(directory.FullName + "\\" + name));
         }
+
+		static public Beagle.Util.Logger Logger = null;
+		//static public Beagle.Util.Logger Logger = Beagle.Util.Logger.Log;
+		static private void Log (string format, params object[] args)
+		{
+			if (Logger != null)
+				Logger.Debug (format, args);
+		}
+
+		static private void Log (Exception e)
+		{
+			if (Logger != null)
+				Logger.Debug (e);
+		}
 		
 		/// <summary> So we can do some byte-to-hexchar conversion below</summary>
 		private static readonly char[] HEX_DIGITS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
