]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
made DebugLogFileSize configurable
authorDipanshu <dipanshu231099@gmail.com>
Thu, 23 Jul 2020 12:08:42 +0000 (17:38 +0530)
committerTill Kamppeter <till.kamppeter@gmail.com>
Thu, 20 Aug 2020 20:08:08 +0000 (22:08 +0200)
(cherry picked from commit d8e30a81bac7bcdfc8d1399bf204328d36ae866e)

utils/cups-browsed.c
utils/cups-browsed.conf.5
utils/cups-browsed.conf.in

index 63ab6d3f090c3b6cbfed8996c0a1ccdae0af5e43..2f8db173cf62a3363bdd786c742b96ea006e5ab6 100644 (file)
@@ -154,7 +154,6 @@ static int  ldap_rebind_proc(LDAP *RebindLDAPHandle,
 #define SAVE_OPTIONS_FILE "/cups-browsed-options-%s"
 #define DEBUG_LOG_FILE "/cups-browsed_log"
 #define DEBUG_LOG_FILE_2 "/cups-browsed_previous_logs"
-#define MAX_LOG_SIZE 30
 
 /* Status of remote printer */
 typedef enum printer_status_e {
@@ -434,6 +433,7 @@ static uint16_t BrowsePort = 631;
 static browsepoll_t **BrowsePoll = NULL;
 static unsigned int NewBrowsePollQueuesShared = 0;
 static unsigned int AllowResharingRemoteCUPSPrinters = 0;
+static unsigned int DebugLogFileSize = 30;
 static size_t NumBrowsePoll = 0;
 static guint update_netifs_sourceid = 0;
 static char local_server_str[1024];
@@ -714,8 +714,6 @@ void copyToFile(FILE **fp1, FILE **fp2){
   char ch;
   while((ch = getc(*fp1)) != EOF)
     putc(ch, *fp2);
-  fclose(*fp1);
-  fclose(*fp2);
 }
 
 void
@@ -742,11 +740,13 @@ debug_printf(const char *format, ...) {
     }
 
     long int log_file_size = findLogFileSize(); 
-    if(log_file_size>(long int)MAX_LOG_SIZE*1024){
+    if(log_file_size>(long int)DebugLogFileSize*1024){
       fclose(lfp);
       FILE *fp1 = fopen(debug_log_file, "r");
       FILE *fp2 = fopen(debug_log_file_bckp, "w");
       copyToFile(&fp1,&fp2);
+      fclose(fp1);
+      fclose(fp2);
       lfp = fopen(debug_log_file, "w");
     }
 }
index 8ef649fd6117213d479d1c365a3433ca46b02e88..1719b784e7b3473469539c98e86d05902722bfdd 100644 (file)
@@ -968,6 +968,16 @@ without jobs.
         AutoShutdownOn NoQueues
         AutoShutdownOn NoJobs
 
+.fam T
+.fi
+The MAX_LOG_SIZE defines the maximum size possible (in KBytes)
+of the log files (cups-browsed_log and cups-browsed_previous_logs)
+that is created using cups-browsed in the debugging mode.
+.PP
+.nf
+.fam C
+        DebugLogFileSize 30
+
 .fam T
 .fi
 The AutoShutdownTimeout directive specifies after how many seconds
index 7e248c511ade58d275e1f44310db7afae9981e56..28e1640fa96ccd6174efa6e5c8f0a9055d5766e5 100644 (file)
@@ -758,3 +758,9 @@ BrowseRemoteProtocols @BROWSEREMOTEPROTOCOLS@
 # shutdown.
 
 # AutoShutdownTimeout 30
+
+# The MAX_LOG_SIZE defines the maximum size possible (in KBytes)
+# of the log files (cups-browsed_log and cups-browsed_previous_logs)
+# that is created using cups-browsed in the debugging mode.
+
+# DebugLogFileSize 30