if (getparam_string("hostalias",buf,HostAliasFile,sizeof(HostAliasFile))>0) return;
if (getparam_bool("keep_temp_log",buf,&KeepTempLog)>0) return;
-
+
+ if (getparam_int("max_successive_log_errors",buf,&NumLogSuccessiveErrors)>0) return;
+
+ if (getparam_int("max_total_log_errors",buf,&NumLogTotalErrors)>0) return;
+
if(strstr(buf,"squid24") != 0) {
squid24=true;
return;
char SortTableJs[256];
//! The name of the file containing the host names to replace by an alias in the report.
char HostAliasFile[512];
+//! The number of consecutive errors allowed in an input log file before the process is interrupted.
+int NumLogSuccessiveErrors;
+/*!
+The total number of errors allowed in an input log file before the process is interrupted. A negative
+value means the process should never fails irrespective of the number of errors found in the input
+log files.
+*/
+int NumLogTotalErrors;
int idate;
int download_count;
dfrom=0;
duntil=0;
KeepTempLog=false;
+ NumLogSuccessiveErrors=3;
+ NumLogTotalErrors=50;
bzero(IncludeUsers, sizeof(IncludeUsers));
bzero(ExcludeString, sizeof(ExcludeString));
int maxdate=0;
int cstatus;
int current_format_idx;
+ int successive_errors=0;
+ int total_errors=0;
int format_count[sizeof(LogFormats)/sizeof(*LogFormats)];
unsigned long int recs1=0UL;
unsigned long int recs2=0UL;
if (log_entry_status!=RLRC_Unknown) break;
}
if (x>=(int)(sizeof(LogFormats)/sizeof(*LogFormats))) {
- debuga(_("Unknown line format found in input log file %s:\n%s\n"),arq,linebuf);
- exit(EXIT_FAILURE);
+ if (++successive_errors>NumLogSuccessiveErrors) {
+ debuga(ngettext("%d consecutive error found in the input log file %s\n",
+ "%d consecutive errors found in the input log file %s\n",successive_errors),successive_errors,arq);
+ exit(EXIT_FAILURE);
+ }
+ if (NumLogTotalErrors>=0 && ++total_errors>NumLogTotalErrors) {
+ debuga(ngettext("%d error found in the input log file (last in %s)\n",
+ "%d errors found in the input log file (last in %s)\n",total_errors),total_errors,arq);
+ exit(EXIT_FAILURE);
+ }
+ debuga(_("The following line read from %s could not be parsed and is ignored\n%s\n"),arq,linebuf);
+ continue;
}
current_format=LogFormats[x];
current_format_idx=x;
/* TRANSLATORS: The argument is the log format name as translated by you. */
debuga(_("Log format identified as \"%s\" for %s\n"),_(current_format->Name),arq);
}
+ successive_errors=0;
}
if (log_entry_status==RLRC_Ignore) {
continue;
}
if (current_format_idx<0 || current_format==NULL) {
- debuga(_("Sarg couldn't determine the format of the input log file %s\n"),arq);
+ debuga(_("Sarg failed to determine the format of the input log file %s\n"),arq);
exit(EXIT_FAILURE);
}
if (log_entry_status==RLRC_InternalError) {
# Use this option only to diagnose a problem with your reports. A better
# alternative is to run sarg from the command line with optino -k.
#keep_temp_log no
+
+# TAG: max_successive_log_errors n
+# Set the number of consecutive errors allowed in the input log file before
+# the reading is aborted with an error.
+#max_successive_log_errors 3
+
+# TAG: max_total_log_errors n
+# The reading of the input log file is interrupted if too many errors are found
+# in the log file. This parameter set the number of errors before the reading
+# is aborted. Set it to -1 to keep reading the logs irrespective of the
+# errors found.
+#
+# Note that the max_successive_log_errors is still taken into account and
+# cannot be disabled.
+#max_total_log_errors 50