[Box Backup-commit] COMMIT r2482 - box/trunk/lib/common

boxbackup-dev at boxbackup.org boxbackup-dev at boxbackup.org
Sun Mar 29 15:08:12 BST 2009


Author: chris
Date: 2009-03-29 15:08:12 +0100 (Sun, 29 Mar 2009)
New Revision: 2482

Modified:
   box/trunk/lib/common/BoxTime.cpp
   box/trunk/lib/common/BoxTime.h
   box/trunk/lib/common/Logging.cpp
   box/trunk/lib/common/Timer.cpp
Log:
Add date to file logger, as requested by Kenny Millington.


Modified: box/trunk/lib/common/BoxTime.cpp
===================================================================
--- box/trunk/lib/common/BoxTime.cpp	2009-03-29 13:51:24 UTC (rev 2481)
+++ box/trunk/lib/common/BoxTime.cpp	2009-03-29 14:08:12 UTC (rev 2482)
@@ -53,7 +53,7 @@
 	return SecondsToBoxTime(time(0));
 }
 
-std::string FormatTime(box_time_t time, bool showMicros)
+std::string FormatTime(box_time_t time, bool includeDate, bool showMicros)
 {
 	std::ostringstream buf;
 
@@ -68,8 +68,16 @@
 		if (localtime_r(&seconds, &tm_now) != NULL)
 	#endif
 	{
-		buf << std::setfill('0') <<
-			std::setw(2) << tm_ptr->tm_hour << ":" << 
+		buf << std::setfill('0');
+
+		if (includeDate)
+		{
+			buf << 	std::setw(4) << (tm_ptr->tm_year + 1900) << "-" <<
+				std::setw(2) << (tm_ptr->tm_mon  + 1) << "-" <<
+				std::setw(2) << (tm_ptr->tm_mday) << " ";
+		}
+
+		buf <<	std::setw(2) << tm_ptr->tm_hour << ":" << 
 			std::setw(2) << tm_ptr->tm_min  << ":" <<
 			std::setw(2) << tm_ptr->tm_sec;
 

Modified: box/trunk/lib/common/BoxTime.h
===================================================================
--- box/trunk/lib/common/BoxTime.h	2009-03-29 13:51:24 UTC (rev 2481)
+++ box/trunk/lib/common/BoxTime.h	2009-03-29 14:08:12 UTC (rev 2482)
@@ -40,6 +40,7 @@
 	return Time;
 }
 
-std::string FormatTime(box_time_t time, bool showMicros = false);
+std::string FormatTime(box_time_t time, bool includeDate,
+	bool showMicros = false);
 
 #endif // BOXTIME__H

Modified: box/trunk/lib/common/Logging.cpp
===================================================================
--- box/trunk/lib/common/Logging.cpp	2009-03-29 13:51:24 UTC (rev 2481)
+++ box/trunk/lib/common/Logging.cpp	2009-03-29 14:08:12 UTC (rev 2482)
@@ -288,7 +288,7 @@
 
 	if (sShowTime)
 	{
-		buf << FormatTime(GetCurrentBoxTime(), sShowTimeMicros);
+		buf << FormatTime(GetCurrentBoxTime(), false, sShowTimeMicros);
 		buf << " ";
 	}
 
@@ -449,7 +449,7 @@
 	Logging::Remove(this);
 
 	std::ostringstream buf;
-	buf << FormatTime(GetCurrentBoxTime(), false);
+	buf << FormatTime(GetCurrentBoxTime(), true, false);
 	buf << " ";
 
 	if (Level <= Log::FATAL)

Modified: box/trunk/lib/common/Timer.cpp
===================================================================
--- box/trunk/lib/common/Timer.cpp	2009-03-29 13:51:24 UTC (rev 2481)
+++ box/trunk/lib/common/Timer.cpp	2009-03-29 14:08:12 UTC (rev 2482)
@@ -357,7 +357,7 @@
 	else
 	{
 		BOX_TRACE(TIMER_ID "initialised for " << timeoutSecs <<
-			" secs, to fire at " << FormatTime(mExpires, true));
+			" secs, to fire at " << FormatTime(mExpires, false, true));
 	}
 	#endif
 




More information about the Boxbackup-commit mailing list