"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/goaccess.c" between
goaccess-1.7.1.tar.gz and goaccess-1.7.2.tar.gz

About: GoAccess is a real-time web log analyzer and interactive viewer ("text-based").

goaccess.c  (goaccess-1.7.1):goaccess.c  (goaccess-1.7.2)
skipping to change at line 800 skipping to change at line 800
* then we break and allow to re-render the UI */ * then we break and allow to re-render the UI */
if (++glog->read % MAX_BATCH_LINES == 0) if (++glog->read % MAX_BATCH_LINES == 0)
break; break;
} }
} }
static void static void
verify_inode (FILE * fp, GLog * glog) { verify_inode (FILE * fp, GLog * glog) {
struct stat fdstat; struct stat fdstat;
if (stat (glog->filename, &fdstat) == -1) if (stat (glog->props.filename, &fdstat) == -1)
FATAL ("Unable to stat the specified log file '%s'. %s", glog->filename, str FATAL ("Unable to stat the specified log file '%s'. %s", glog->props.filenam
error (errno)); e,
strerror (errno));
glog->size = fdstat.st_size; glog->props.size = fdstat.st_size;
/* Either the log got smaller, probably was truncated so start reading from 0 /* Either the log got smaller, probably was truncated so start reading from 0
* and reset snippet. * and reset snippet.
* If the log changed its inode, more likely the log was rotated, so we set * If the log changed its inode, more likely the log was rotated, so we set
* the initial snippet for the new log for future iterations */ * the initial snippet for the new log for future iterations */
if (fdstat.st_ino != glog->inode || glog->snippet[0] == '\0' || 0 == glog->siz e) { if (fdstat.st_ino != glog->props.inode || glog->snippet[0] == '\0' || 0 == glo g->props.size) {
glog->length = glog->bytes = 0; glog->length = glog->bytes = 0;
set_initial_persisted_data (glog, fp, glog->filename); set_initial_persisted_data (glog, fp, glog->props.filename);
} }
glog->inode = fdstat.st_ino; glog->props.inode = fdstat.st_ino;
} }
/* Process appended log data /* Process appended log data
* *
* If nothing changed, 0 is returned. * If nothing changed, 0 is returned.
* If log file changed, 1 is returned. */ * If log file changed, 1 is returned. */
static int static int
perform_tail_follow (GLog * glog) { perform_tail_follow (GLog * glog) {
FILE *fp = NULL; FILE *fp = NULL;
char buf[READ_BYTES + 1] = { 0 }; char buf[READ_BYTES + 1] = { 0 };
uint16_t len = 0; uint16_t len = 0;
uint64_t length = 0; uint64_t length = 0;
if (glog->filename[0] == '-' && glog->filename[1] == '\0') { if (glog->props.filename[0] == '-' && glog->props.filename[1] == '\0') {
parse_tail_follow (glog, glog->pipe); parse_tail_follow (glog, glog->pipe);
/* did we read something from the pipe? */ /* did we read something from the pipe? */
if (0 == glog->bytes) if (0 == glog->bytes)
return 0; return 0;
glog->length += glog->bytes; glog->length += glog->bytes;
goto out; goto out;
} }
length = file_size (glog->filename); length = file_size (glog->props.filename);
/* file hasn't changed */ /* file hasn't changed */
/* ###NOTE: This assumes the log file being read can be of smaller size, e.g., /* ###NOTE: This assumes the log file being read can be of smaller size, e.g.,
* rotated/truncated file or larger when data is appended */ * rotated/truncated file or larger when data is appended */
if (length == glog->length) if (length == glog->length)
return 0; return 0;
if (!(fp = fopen (glog->filename, "r"))) if (!(fp = fopen (glog->props.filename, "r")))
FATAL ("Unable to read the specified log file '%s'. %s", glog->filename, str FATAL ("Unable to read the specified log file '%s'. %s", glog->props.filenam
error (errno)); e,
strerror (errno));
verify_inode (fp, glog); verify_inode (fp, glog);
len = MIN (glog->snippetlen, length); len = MIN (glog->snippetlen, length);
/* This is not ideal, but maybe the only reliable way to know if the /* This is not ideal, but maybe the only reliable way to know if the
* current log looks different than our first read/parse */ * current log looks different than our first read/parse */
if ((fread (buf, len, 1, fp)) != 1 && ferror (fp)) if ((fread (buf, len, 1, fp)) != 1 && ferror (fp))
FATAL ("Unable to fread the specified log file '%s'", glog->filename); FATAL ("Unable to fread the specified log file '%s'", glog->props.filename);
/* For the case where the log got larger since the last iteration, we attempt /* For the case where the log got larger since the last iteration, we attempt
* to compare the first READ_BYTES against the READ_BYTES we had since the las t * to compare the first READ_BYTES against the READ_BYTES we had since the las t
* parse. If it's different, then it means the file may got truncated but grew * parse. If it's different, then it means the file may got truncated but grew
* faster than the last iteration (odd, but possible), so we read from 0* */ * faster than the last iteration (odd, but possible), so we read from 0* */
if (glog->snippet[0] != '\0' && buf[0] != '\0' && memcmp (glog->snippet, buf, len) != 0) if (glog->snippet[0] != '\0' && buf[0] != '\0' && memcmp (glog->snippet, buf, len) != 0)
glog->length = glog->bytes = 0; glog->length = glog->bytes = 0;
if (!fseeko (fp, glog->length, SEEK_SET)) if (!fseeko (fp, glog->length, SEEK_SET))
parse_tail_follow (glog, fp); parse_tail_follow (glog, fp);
fclose (fp); fclose (fp);
glog->length += glog->bytes; glog->length += glog->bytes;
/* insert the inode of the file parsed and the last line parsed */ /* insert the inode of the file parsed and the last line parsed */
if (glog->inode) { if (glog->props.inode) {
glog->lp.line = glog->read; glog->lp.line = glog->read;
glog->lp.size = glog->size; glog->lp.size = glog->props.size;
ht_insert_last_parse (glog->inode, glog->lp); ht_insert_last_parse (glog->props.inode, glog->lp);
} }
out: out:
return 1; return 1;
} }
/* Loop over and perform a follow for the given logs */ /* Loop over and perform a follow for the given logs */
static void static void
tail_loop_html (Logs * logs) { tail_loop_html (Logs * logs) {
skipping to change at line 1303 skipping to change at line 1305
/* will loop in here */ /* will loop in here */
get_keys (logs); get_keys (logs);
} }
/* Set locale */ /* Set locale */
static void static void
set_locale (void) { set_locale (void) {
char *loc_ctype; char *loc_ctype;
setlocale (LC_ALL, ""); setlocale (LC_ALL, "");
#ifdef ENABLE_NLS
bindtextdomain (PACKAGE, LOCALEDIR); bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE); textdomain (PACKAGE);
#endif
loc_ctype = getenv ("LC_CTYPE"); loc_ctype = getenv ("LC_CTYPE");
if (loc_ctype != NULL) if (loc_ctype != NULL)
setlocale (LC_CTYPE, loc_ctype); setlocale (LC_CTYPE, loc_ctype);
else if ((loc_ctype = getenv ("LC_ALL"))) else if ((loc_ctype = getenv ("LC_ALL")))
setlocale (LC_CTYPE, loc_ctype); setlocale (LC_CTYPE, loc_ctype);
else else
setlocale (LC_CTYPE, ""); setlocale (LC_CTYPE, "");
} }
skipping to change at line 1476 skipping to change at line 1480
set_io (&pipe); set_io (&pipe);
/* init glog */ /* init glog */
if (!(logs = init_logs (conf.filenames_idx))) if (!(logs = init_logs (conf.filenames_idx)))
FATAL (ERR_NO_DATA_PASSED); FATAL (ERR_NO_DATA_PASSED);
set_signal_data (logs); set_signal_data (logs);
for (i = 0; i < logs->size; ++i) for (i = 0; i < logs->size; ++i)
if (logs->glog[i].filename[0] == '-' && logs->glog[i].filename[1] == '\0') if (logs->glog[i].props.filename[0] == '-' && logs->glog[i].props.filename[1 ] == '\0')
logs->glog[i].pipe = pipe; logs->glog[i].pipe = pipe;
/* init parsing spinner */ /* init parsing spinner */
parsing_spinner = new_gspinner (); parsing_spinner = new_gspinner ();
parsing_spinner->processed = &(logs->processed); parsing_spinner->processed = &(logs->processed);
parsing_spinner->filename = &(logs->filename); parsing_spinner->filename = &(logs->filename);
/* init reverse lookup thread */ /* init reverse lookup thread */
gdns_init (); gdns_init ();
 End of changes. 14 change blocks. 
17 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)