-- adding hostinfo and time to GlobalOutput

Summary:
- makes thrift errors a lot more useful

Reviewed By: jwang, mcslee

Test Plan: tested with search


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665249 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/Thrift.h b/lib/cpp/src/Thrift.h
index 4a3df65..0b13bae 100644
--- a/lib/cpp/src/Thrift.h
+++ b/lib/cpp/src/Thrift.h
@@ -28,7 +28,7 @@
 
 class TOutput{
 public:
-  TOutput() : f_(perror) {}
+  TOutput() : f_(&perrorTimeWrapper) {}
 
   inline void setOutputFunction(void (*function)(const char *)){
     f_ = function;
@@ -38,6 +38,15 @@
     f_(message);
   }
 
+  inline static void perrorTimeWrapper(const char* msg) {
+    time_t now;
+    char dbgtime[25];
+    time(&now);
+    ctime_r(&now, dbgtime);
+    dbgtime[24] = 0;
+    fprintf(stderr, "%s ", dbgtime);
+    perror(msg);
+  }
 private:
   void (*f_)(const char *);
 };