[Box Backup-commit] COMMIT r1170 - in box/chris/merge: bin/bbackupd lib/backupclient

boxbackup-dev at fluffy.co.uk boxbackup-dev at fluffy.co.uk
Tue Nov 14 05:12:03 GMT 2006


Author: chris
Date: 2006-11-14 05:12:03 +0000 (Tue, 14 Nov 2006)
New Revision: 1170

Modified:
   box/chris/merge/bin/bbackupd/BackupClientContext.cpp
   box/chris/merge/bin/bbackupd/BackupClientContext.h
   box/chris/merge/bin/bbackupd/BackupDaemon.cpp
   box/chris/merge/lib/backupclient/BackupDaemonConfigVerify.cpp
Log:
Add ExtendedLogFile option to bbackupd config (refs #9)


Modified: box/chris/merge/bin/bbackupd/BackupClientContext.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/BackupClientContext.cpp	2006-11-13 20:04:01 UTC (rev 1169)
+++ box/chris/merge/bin/bbackupd/BackupClientContext.cpp	2006-11-14 05:12:03 UTC (rev 1170)
@@ -35,13 +35,21 @@
 // --------------------------------------------------------------------------
 //
 // Function
-//		Name:    BackupClientContext::BackupClientContext(BackupDaemon &, TLSContext &, const std::string &, int32_t, bool)
+//		Name:    BackupClientContext::BackupClientContext(BackupDaemon &, TLSContext &, const std::string &, int32_t, bool, bool, std::string)
 //		Purpose: Constructor
 //		Created: 2003/10/08
 //
 // --------------------------------------------------------------------------
-BackupClientContext::BackupClientContext(BackupDaemon &rDaemon, TLSContext &rTLSContext, const std::string &rHostname,
-			int32_t AccountNumber, bool ExtendedLogging)
+BackupClientContext::BackupClientContext
+(
+	BackupDaemon &rDaemon, 
+	TLSContext &rTLSContext, 
+	const std::string &rHostname,
+	int32_t AccountNumber, 
+	bool ExtendedLogging,
+	bool ExtendedLogToFile,
+	std::string ExtendedLogFile
+)
 	: mrDaemon(rDaemon),
 	  mrTLSContext(rTLSContext),
 	  mHostname(rHostname),
@@ -49,6 +57,9 @@
 	  mpSocket(0),
 	  mpConnection(0),
 	  mExtendedLogging(ExtendedLogging),
+	  mExtendedLogToFile(ExtendedLogToFile),
+	  mExtendedLogFile(ExtendedLogFile),
+	  mpExtendedLogFileHandle(NULL),
 	  mClientStoreMarker(ClientStoreMarker_NotKnown),
 	  mpDeleteList(0),
 	  mpCurrentIDMap(0),
@@ -126,6 +137,24 @@
 		// Set logging option
 		mpConnection->SetLogToSysLog(mExtendedLogging);
 		
+		if (mExtendedLogToFile)
+		{
+			ASSERT(mpExtendedLogFileHandle == NULL);
+			
+			mpExtendedLogFileHandle = fopen(
+				mExtendedLogFile.c_str(), "w");
+
+			if (!mpExtendedLogFileHandle)
+			{
+				::syslog(LOG_ERR, "Failed to open extended "
+					"log file: %s", strerror(errno));
+			}
+			else
+			{
+				mpConnection->SetLogToFile(mpExtendedLogFileHandle);
+			}
+		}
+		
 		// Handshake
 		mpConnection->Handshake();
 		
@@ -256,6 +285,12 @@
 		delete mpDeleteList;
 		mpDeleteList = 0;
 	}
+
+	if (mpExtendedLogFileHandle != NULL)
+	{
+		fclose(mpExtendedLogFileHandle);
+		mpExtendedLogFileHandle = NULL;
+	}
 }
 
 

Modified: box/chris/merge/bin/bbackupd/BackupClientContext.h
===================================================================
--- box/chris/merge/bin/bbackupd/BackupClientContext.h	2006-11-13 20:04:01 UTC (rev 1169)
+++ box/chris/merge/bin/bbackupd/BackupClientContext.h	2006-11-14 05:12:03 UTC (rev 1170)
@@ -35,8 +35,16 @@
 class BackupClientContext : public DiffTimer
 {
 public:
-	BackupClientContext(BackupDaemon &rDaemon, TLSContext &rTLSContext, const std::string &rHostname,
-		int32_t AccountNumber, bool ExtendedLogging);
+	BackupClientContext
+	(
+		BackupDaemon &rDaemon, 
+		TLSContext &rTLSContext, 
+		const std::string &rHostname,
+		int32_t AccountNumber, 
+		bool ExtendedLogging,
+		bool ExtendedLogToFile,
+		std::string ExtendedLogFile
+	);
 	virtual ~BackupClientContext();
 private:
 	BackupClientContext(const BackupClientContext &);
@@ -197,6 +205,9 @@
 	SocketStreamTLS *mpSocket;
 	BackupProtocolClient *mpConnection;
 	bool mExtendedLogging;
+	bool mExtendedLogToFile;
+	std::string mExtendedLogFile;
+	FILE* mpExtendedLogFileHandle;
 	int64_t mClientStoreMarker;
 	BackupClientDeleteList *mpDeleteList;
 	const BackupClientInodeToIDMap *mpCurrentIDMap;

Modified: box/chris/merge/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/chris/merge/bin/bbackupd/BackupDaemon.cpp	2006-11-13 20:04:01 UTC (rev 1169)
+++ box/chris/merge/bin/bbackupd/BackupDaemon.cpp	2006-11-14 05:12:03 UTC (rev 1170)
@@ -697,9 +697,25 @@
 				SetState(State_Connected);
 				::syslog(LOG_INFO, "Beginning scan of local files");
 
-				// Then create a client context object (don't just connect, as this may be unnecessary)
-				BackupClientContext clientContext(*this, tlsContext, conf.GetKeyValue("StoreHostname"),
-					conf.GetKeyValueInt("AccountNumber"), conf.GetKeyValueBool("ExtendedLogging"));
+				std::string extendedLogFile;
+				if (conf.KeyExists("ExtendedLogFile"))
+				{
+					extendedLogFile = conf.GetKeyValue(
+						"ExtendedLogFile");
+				}
+				
+				// Then create a client context object (don't 
+				// just connect, as this may be unnecessary)
+				BackupClientContext clientContext
+				(
+					*this, 
+					tlsContext, 
+					conf.GetKeyValue("StoreHostname"),
+					conf.GetKeyValueInt("AccountNumber"), 
+					conf.GetKeyValueBool("ExtendedLogging"),
+					conf.KeyExists("ExtendedLogFile"),
+					extendedLogFile
+				);
 					
 				// Set up the sync parameters
 				BackupClientDirectoryRecord::SyncParams params(*this, clientContext);

Modified: box/chris/merge/lib/backupclient/BackupDaemonConfigVerify.cpp
===================================================================
--- box/chris/merge/lib/backupclient/BackupDaemonConfigVerify.cpp	2006-11-13 20:04:01 UTC (rev 1169)
+++ box/chris/merge/lib/backupclient/BackupDaemonConfigVerify.cpp	2006-11-14 05:12:03 UTC (rev 1170)
@@ -81,7 +81,8 @@
 	{"FileTrackingSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
 	{"DiffingUploadSizeThreshold", 0, ConfigTest_Exists | ConfigTest_IsInt, 0},
 	{"StoreHostname", 0, ConfigTest_Exists, 0},
-	{"ExtendedLogging",	"no", ConfigTest_IsBool, 0},			// make value "yes" to enable in config file
+	{"ExtendedLogging",	"no", ConfigTest_IsBool, 0}, // extended log to syslog
+	{"ExtendedLogFile",	NULL, 0, 0}, // extended log to a file
 
 	{"CommandSocket", 0, 0, 0},				// not compulsory to have this
 	{"KeepAliveTime", 0, ConfigTest_IsInt, 0},				// optional




More information about the Boxbackup-commit mailing list