Bug 142496 - Ktorrent needs an option to control the log file size
Summary: Ktorrent needs an option to control the log file size
Status: RESOLVED FIXED
Alias: None
Product: ktorrent
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist (vote)
Target Milestone: ---
Assignee: Joris Guisson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-04 11:04 UTC by Donatas Glodenis
Modified: 2007-05-19 13:06 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Donatas Glodenis 2007-03-04 11:04:14 UTC
Version:           2.1 (using KDE 3.5.5, Kubuntu (edgy) 4:3.5.5-0ubuntu3.1)
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.17-11-generic

After some time in use Ktorrent log file got to 90 MB size. I could not find an option to limit the size it can grow to, so I think there must be some option created in the configuration dialogs.
Comment 1 Joris Guisson 2007-05-19 12:47:19 UTC
We will add an automatic log rotate after 10 MB, don't see much need in actually having this configurable.
Comment 2 Joris Guisson 2007-05-19 13:06:20 UTC
SVN commit 666273 by guisson:

Auto rotate log when it gets larger then 10 MB

BUG: 142496


 M  +17 -2     log.cpp  


--- trunk/extragear/network/ktorrent/libktorrent/util/log.cpp #666272:666273
@@ -38,6 +38,8 @@
 
 namespace bt
 {
+	const Uint32 MAX_LOG_FILE_SIZE = 10 * 1024 * 1024; // 10 MB
+	
 	class Log::Private
 	{
 	public:
@@ -103,8 +105,8 @@
 		{
 			tmp += line;
 		}
-
-		void endline()
+		
+		void finishLine()
 		{
 			*out << QDateTime::currentDateTime().toString() << ": " << tmp << ::endl;
 			fptr.flush();
@@ -123,6 +125,19 @@
 			}
 			tmp = "";
 		}
+
+		void endline()
+		{
+			finishLine();
+			if (fptr.size() > MAX_LOG_FILE_SIZE)
+			{
+				// calling setOutputFile will rotate the logs
+				tmp = "Log larger then 10 MB, rotating";
+				finishLine();
+				QString file = fptr.name();
+				setOutputFile(file);
+			}
+		}
 	};
 	
 	Log::Log()