Index: gs2-extensions/tdb-edit/trunk/src/src/tdbdel-src/tdbdel.cpp
===================================================================
--- gs2-extensions/tdb-edit/trunk/src/src/tdbdel-src/tdbdel.cpp	(revision 24364)
+++ gs2-extensions/tdb-edit/trunk/src/src/tdbdel-src/tdbdel.cpp	(revision 24365)
@@ -32,4 +32,6 @@
 #include <iostream>
 #endif
+
+#include <cstdlib>
 
 #include <fcntl.h>
Index: gs2-extensions/tdb-edit/trunk/src/src/tdbget-src/tdbget.cpp
===================================================================
--- gs2-extensions/tdb-edit/trunk/src/src/tdbget-src/tdbget.cpp	(revision 24364)
+++ gs2-extensions/tdb-edit/trunk/src/src/tdbget-src/tdbget.cpp	(revision 24365)
@@ -32,4 +32,6 @@
 #include <iostream>
 #endif
+
+#include <cstdlib>
 
 #include <fcntl.h>
Index: gs2-extensions/tdb-edit/trunk/src/src/tdbkeys-src/tdbkeys.cpp
===================================================================
--- gs2-extensions/tdb-edit/trunk/src/src/tdbkeys-src/tdbkeys.cpp	(revision 24364)
+++ gs2-extensions/tdb-edit/trunk/src/src/tdbkeys-src/tdbkeys.cpp	(revision 24365)
@@ -32,4 +32,6 @@
 #include <iostream>
 #endif
+
+#include <cstdlib>
 
 #include <fcntl.h>
Index: gs2-extensions/tdb-edit/trunk/src/src/tdbset-src/tdbset.cpp
===================================================================
--- gs2-extensions/tdb-edit/trunk/src/src/tdbset-src/tdbset.cpp	(revision 24364)
+++ gs2-extensions/tdb-edit/trunk/src/src/tdbset-src/tdbset.cpp	(revision 24365)
@@ -32,4 +32,6 @@
 #include <iostream>
 #endif
+
+#include <cstdlib>
 
 #include <fcntl.h>
Index: gs2-extensions/tdb-edit/trunk/src/src/txt2tdb-src/txt2tdb.cpp
===================================================================
--- gs2-extensions/tdb-edit/trunk/src/src/txt2tdb-src/txt2tdb.cpp	(revision 24364)
+++ gs2-extensions/tdb-edit/trunk/src/src/txt2tdb-src/txt2tdb.cpp	(revision 24365)
@@ -33,4 +33,8 @@
 #include <iostream>
 #endif
+
+#include <cstdlib>
+
+#include <time.h>
 
 #include "tdb.h"
@@ -46,18 +50,47 @@
 #endif
 
+/**
+ */
 void
 printUsage (char *program_name)
 {
-  cerr << "usage: " << program_name << " [options] database-name" << endl << endl;
+  cerr << "usage: " << program_name << " [-append] database-name [-debug]" << endl << endl;
   cerr << "options:" << endl;
-  cerr << " -append        append to existing database" << endl << endl;
+  cerr << " -append        append to existing database" << endl;
+  cerr << " -debug         add timing information to database" << endl << endl; 
 }
 /** printUsage() **/
 
+void
+debugLog(TDB_CONTEXT * tdb, char * msg_content)
+{
+  // Since this log will be used to track order of events, we need an indicator
+  // of time
+  time_t seconds = time(NULL);
+  // We also need some idea of what thread this is - let's try and use the PID
+  pid_t process_id = getpid();
+  // Append the message to the entry in the db (fixed key "debuglog")
+  TDB_DATA key_datum;
+  key_datum.dptr = (unsigned char *)"debuglog";
+  key_datum.dsize = 8;
+  text_t message = "[" + text_t(seconds) + "][" + text_t(process_id) + "] " + msg_content + "\n"; 
+  TDB_DATA msg_datum;
+  msg_datum.dptr = (unsigned char *) message.getcstr();
+  msg_datum.dsize = message.size();
+  if (tdb_append(tdb, key_datum, msg_datum) != 0)
+  {
+    cerr << "txt2tdb::debugLog() - tdb_append returned an error" << endl;
+    exit (0);
+  }
+}
+/** debugLog() **/
+
+/**
+ */
 int
 main (int argc, char *argv[])
 {
   // sanity check
-  if (argc != 2 && argc != 3)
+  if (2 > argc || argc > 4)
   {
     printUsage (argv[0]);
@@ -68,4 +101,5 @@
   int append = 0;
   int delkey = 0;
+  int debug = 0;
   if (argc == 3)
   {
@@ -74,4 +108,24 @@
       append = 1;
       dbname = argv[2];
+    }
+    else if (strcmp(argv[2], "-debug") == 0)
+    {
+      dbname = argv[1];
+      debug = 1;
+    }
+    else
+    {
+      cerr << argv[1] << " is not a valid option." << endl << endl;
+      printUsage(argv[0]);
+      exit (0);
+    }
+  }
+  else if (argc == 4)
+  {
+    if (strcmp (argv[1], "-append") == 0 && strcmp (argv[3], "-debug") == 0)
+    {
+      append = 1;
+      dbname = argv[2];
+      debug = 1;
     }
     else
@@ -94,4 +148,7 @@
     tdb_flags = TDB_CLEAR_IF_FIRST;
   }
+  // Disable file IO for testing purposes
+  /*tdb_flags = tdb_flags | TDB_INTERNAL;*/
+
   int tdb_store_flags = TDB_DEFAULT; // used later when storing
   int open_flags = O_RDWR | O_CREAT;
@@ -99,6 +156,12 @@
   if (!tdb)
   {
-    cerr << "couldn't create " << dbname << endl;
+    cerr << "txt2tdb::main() - couldn't create " << dbname << endl;
     exit (0);
+  }
+
+  // If we are debugging, we'll write that we just opened the connection
+  if (debug)
+  {
+    debugLog(tdb, "opened connection to database for read/write");
   }
 
@@ -226,4 +289,10 @@
   }
 
+  // If we are debugging, we'll write that we are about to close the connection
+  if (debug)
+  {
+    debugLog(tdb, "closing connection to database");
+  }
+
   // Close the database connection
   if (tdb_close(tdb) < 0)
