if (getparam_bool("show_read_statistics",buf,&ShowReadStatistics)>0) return;
+ if (getparam_bool("show_read_percent",buf,&ShowReadPercent)>0) return;
+
if (getparam_list("topuser_fields",SET_LIST(topuserfields_values),buf,&TopUserFields)>0) return;
if (getparam_bool("bytes_in_sites_users_report",buf,&BytesInSitesUsersReport)>0) return;
char DataFileDelimiter[3];
unsigned long int DataFileFields;
unsigned long int DataFileUrl;
+//! if \c true, show the number of lines read from the input log file during the reading of the file.
bool ShowReadStatistics;
+/*!
+If \c true, the read statistics also includes the percent of the number of lines read.
+
+Beware that it requires two readings of the input log file. It is not possible if the
+input log file is stdin or a pipe.
+*/
+bool ShowReadPercent;
char IndexSortOrder[5];
char DansGuardianConf[MAXLEN];
bool DansguardianFilterOutDate;
DataFileFields=DATA_FIELD_USER | DATA_FIELD_DATE | DATA_FIELD_TIME | DATA_FIELD_URL | DATA_FIELD_CONNECT |
DATA_FIELD_BYTES | DATA_FIELD_IN_CACHE | DATA_FIELD_OUT_CACHE | DATA_FIELD_ELAPSED;
ShowReadStatistics=true;
+ ShowReadPercent=false;
strcpy(IndexSortOrder,"D");
ShowSargInfo=true;
ShowSargLogo=true;
ilf=ILF_Unknown;
download_flag=false;
+ recs1=0UL;
+ recs2=0UL;
+
// pre-read the file only if we have to show stats
- if (ShowReadStatistics && !from_stdin && !from_pipe) {
+ if (ShowReadStatistics && ShowReadPercent && !from_stdin && !from_pipe) {
size_t nread,i;
bool skipcr=false;
char tmp4[MAXLEN];
- recs1=0UL;
- recs2=0UL;
-
while ((nread=fread(tmp4,1,sizeof(tmp4),fp_in))>0) {
for (i=0 ; i<nread ; i++)
if (skipcr) {
}
recs2++;
- if( ShowReadStatistics && !from_stdin && !from_pipe && --OutputNonZero<=0) {
- double perc = recs2 * 100. / recs1 ;
- printf(_("SARG: Records in file: %lu, reading: %3.2lf%%"),recs2,perc);
+ if (ShowReadStatistics && --OutputNonZero<=0) {
+ if (recs1>0) {
+ double perc = recs2 * 100. / recs1 ;
+ printf(_("SARG: Records in file: %lu, reading: %3.2lf%%"),recs2,perc);
+ } else {
+ printf(_("SARG: Records in file: %lu"),recs2);
+ }
putchar('\r');
fflush (stdout);
OutputNonZero = REPORT_EVERY_X_LINES ;
pclose(fp_in);
else {
fclose(fp_in);
- if( ShowReadStatistics )
- printf(_("SARG: Records in file: %lu, reading: %3.2f%%\n"),recs1, (float) 100 );
+ if (ShowReadStatistics) {
+ if (ShowReadPercent)
+ printf(_("SARG: Records in file: %lu, reading: %3.2f%%\n"),recs2, (float) 100 );
+ else
+ printf(_("SARG: Records in file: %lu\n"),recs2);
+ }
}
}
}
#show_successful_message yes
# TAG: show_read_statistics yes|no
-# Shows some reading statistics.
+# Shows how many lines have been read from the current input log file.
#
-#show_read_statistics yes
+#show_read_statistics no
+
+# TAG: show_read_percent yes|no
+# Shows how many percents have been read from the current input log file.
+#
+# Beware that this feature requires to read the input log file once to
+# count the number of lines and then a second time to actually parse it.
+# You can save some time by disabling it.
+#
+#show_read_percent no
# TAG: topuser_fields
# Which fields must be in Topuser report.