]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - readlog.c
Produce a user agent log if the information is in the extended log
[thirdparty/sarg.git] / readlog.c
index d81032e79315a77a4bf787ede68741d38d19ff6d..3805de0cb35f4355509a154933aa6fe797108e72 100644 (file)
--- a/readlog.c
+++ b/readlog.c
@@ -332,6 +332,7 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq)
        struct userfilestruct *ufile1;
        struct ReadLogStruct log_entry;
        struct LogLineStruct log_line;
+       FILE *UseragentLog=NULL;
 
        LogLine_Init(&log_line);
        LogLine_File(&log_line,arq);
@@ -714,6 +715,12 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq)
                denied_write(&log_entry);
                authfail_write(&log_entry);
                if (download_flag) download_write(&log_entry,download_url);
+               if (log_entry.UserAgent)
+               {
+                       if (!UseragentLog)
+                               UseragentLog=UserAgent_Open();
+                       UserAgent_Write(UseragentLog,log_entry.Ip,log_entry.User,log_entry.UserAgent);
+               }
 
                if (log_line.current_format!=&ReadSargLog) {
                        if (period.start.tm_year==0 || idata<mindate || compare_date(&period.start,&log_entry.EntryTime)>0){
@@ -744,6 +751,7 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq)
                debuga(__FILE__,__LINE__,_("Read error in \"%s\": %s\n"),arq,FileObject_GetLastCloseError());
                exit(EXIT_FAILURE);
        }
+       if (UseragentLog) fclose(UseragentLog);
        if (ShowReadStatistics) {
                if (ShowReadPercent)
                        printf(_("SARG: Records in file: %lu, reading: %3.2f%%\n"),recs2, (float) 100 );