[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] conga/ricci/modules/log LogParser.cpp



CVSROOT:	/cvs/cluster
Module name:	conga
Changes by:	rmccabe sourceware org	2006-11-08 20:14:21

Modified files:
	ricci/modules/log: LogParser.cpp 

Log message:
	make the log module ignore files whose mtime is older than current time minus max age

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/log/LogParser.cpp.diff?cvsroot=cluster&r1=1.7&r2=1.8

--- conga/ricci/modules/log/LogParser.cpp	2006/10/23 18:43:35	1.7
+++ conga/ricci/modules/log/LogParser.cpp	2006/11/08 20:14:21	1.8
@@ -165,7 +165,8 @@
 
 set<String>&
 get_files(const String& path_,
-	  set<String>& files)
+	  set<String>& files,
+          time_t age_time)
 {
   String path = utils::rstrip(utils::strip(path_), "/");
   if (path.empty() || path.find_first_of(" ; & $ ` ? > < ' \" ; | \\ * \n \t") != path.npos)
@@ -178,11 +179,12 @@
     //    throw String("unable to stat ") + path;
     return files;
   if (S_ISREG(st.st_mode)) {
-    files.insert(path);
+    if (st.st_mtime >= age_time)
+      files.insert(path);
     
     // get rotated logs
     for (int i=0; i<25; i++)
-      get_files(path + "." + utils::to_string(i), files);
+      get_files(path + "." + utils::to_string(i), files, age_time);
     
     return files;
   } else if (S_ISDIR(st.st_mode))
@@ -204,7 +206,7 @@
       if (kid_path == "." || kid_path == "..")
 	continue;
       kid_path = path + "/" + kid_path;
-      get_files(kid_path, files);
+      get_files(kid_path, files, age_time);
     }
   } catch ( ... ) {
     closedir(d);
@@ -366,6 +368,13 @@
 		       const list<String>& paths)
 {
   set<LogEntry> ret;
+  time_t age_time = time(NULL);
+
+  if ((long long) age_time - age < 0)
+    age_time = 0;
+  else
+    age_time -= age;
+  
   
   // set of requested tags
   set<String> req_tags(domains.begin(), domains.end());
@@ -375,10 +384,10 @@
   for (list<String>::const_iterator iter = paths.begin();
        iter != paths.end();
        iter++)
-    get_files(*iter, files);
+    get_files(*iter, files, age_time);
   if (files.empty()) {
-    get_files("/var/log/messages", files);
-    get_files("/var/log/syslog", files);
+    get_files("/var/log/messages", files, age_time);
+    get_files("/var/log/syslog", files, age_time);
   }
   
   // process log files


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]