Commit a1da0e1d authored by Geoff Simmons's avatar Geoff Simmons

varnishevent - moved output formatting into format.c

	output formats now compiled at init time
	and formatted with callbacks at runtime
parent 8bc9e7dc
......@@ -17,6 +17,7 @@ varnishevent_SOURCES = \
config.c \
log.c \
monitor.c \
format.c \
$(top_builddir)/lib/libvarnish/assert.c \
$(top_builddir)/lib/libvarnish/flopen.c \
$(top_builddir)/lib/libvarnish/version.c \
......
......@@ -181,7 +181,7 @@ CONF_Init(void)
config.varnish_bindump[0] = '\0';
config.syslog_facility = LOG_LOCAL0;
config.monitor_interval = 30;
config.output_bufsiz = 4096;
config.output_bufsiz = BUFSIZ;
config.max_reclen = DEFAULT_MAX_RECLEN;
config.max_headers = DEFAULT_MAX_HEADERS;
......
This diff is collapsed.
......@@ -370,6 +370,7 @@ main(int argc, char *argv[])
int a_flag = 0, D_flag = 0, format_flag = 0;
const char *P_arg = NULL;
const char *w_arg = NULL;
char errstr[BUFSIZ], i_arg[BUFSIZ];
struct vpf_fh *pfh = NULL;
FILE *of;
......@@ -466,6 +467,11 @@ main(int argc, char *argv[])
LOG_Log(LOG_INFO, "initializing (%s)", VCS_version);
if (FMT_Init(errstr) != 0) {
LOG_Log(LOG_ALERT, "Error in output formats: %s", errstr);
exit(EXIT_FAILURE);
}
AZ(pthread_mutexattr_init(&attr_lock));
AZ(pthread_condattr_init(&attr_cond));
......@@ -509,6 +515,12 @@ main(int argc, char *argv[])
TIM_sleep(1);
}
FMT_Get_i_Arg(i_arg);
assert(VSL_Arg(vd, 'i', i_arg) > 0);
LOG_Log(LOG_INFO, "Reading varnish instance %s, SHM tags: %s",
VSM_Name(vd), i_arg);
while (VSL_Dispatch(vd, h_ncsa, of) >= 0) {
if (fflush(of) != 0) {
perror(w_arg);
......@@ -523,6 +535,8 @@ main(int argc, char *argv[])
WRT_Halt();
MON_Shutdown();
FMT_Shutdown();
LOG_Close();
exit(0);
}
......@@ -34,7 +34,9 @@
#include <pthread.h>
#include <sys/types.h>
#include "varnishapi.h"
#include "vqueue.h"
#include "vsb.h"
/* Defaults from Varnish 3.0.3 */
#define DEFAULT_MAX_RECLEN 255 /* shm_reclen */
......@@ -221,3 +223,9 @@ typedef enum {
void MON_Start(void);
void MON_Shutdown(void);
void MON_StatsUpdate(stats_update_t update);
/* format.c */
int FMT_Init(char *err);
void FMT_Get_i_Arg(char *i_arg);
void FMT_Format(logline_t *ll, struct vsb *os);
void FMT_Shutdown(void);
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment