output: cleanup JSON logging

pull/1753/head
Victor Julien 10 years ago
parent ad5a753dde
commit c80990fe10

@ -367,9 +367,7 @@ int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer *buffer)
if (r != 0) if (r != 0)
return TM_ECODE_OK; return TM_ECODE_OK;
LogFileWrite(file_ctx, buffer, LogFileWrite(file_ctx, buffer);
(char *)MEMBUFFER_BUFFER(buffer),
MEMBUFFER_OFFSET(buffer));
return 0; return 0;
} }

@ -615,10 +615,11 @@ static int LogFileWriteRedis(LogFileCtx *file_ctx, char *string, size_t string_
} }
#endif #endif
int LogFileWrite(LogFileCtx *file_ctx, MemBuffer *buffer, char *string, size_t string_len) int LogFileWrite(LogFileCtx *file_ctx, MemBuffer *buffer)
{ {
if (file_ctx->type == LOGFILE_TYPE_SYSLOG) { if (file_ctx->type == LOGFILE_TYPE_SYSLOG) {
syslog(file_ctx->syslog_setup.alert_syslog_level, "%s", string); syslog(file_ctx->syslog_setup.alert_syslog_level, "%s",
(const char *)MEMBUFFER_BUFFER(buffer));
} else if (file_ctx->type == LOGFILE_TYPE_FILE || } else if (file_ctx->type == LOGFILE_TYPE_FILE ||
file_ctx->type == LOGFILE_TYPE_UNIX_DGRAM || file_ctx->type == LOGFILE_TYPE_UNIX_DGRAM ||
file_ctx->type == LOGFILE_TYPE_UNIX_STREAM) file_ctx->type == LOGFILE_TYPE_UNIX_STREAM)
@ -633,7 +634,8 @@ int LogFileWrite(LogFileCtx *file_ctx, MemBuffer *buffer, char *string, size_t s
#ifdef HAVE_LIBHIREDIS #ifdef HAVE_LIBHIREDIS
else if (file_ctx->type == LOGFILE_TYPE_REDIS) { else if (file_ctx->type == LOGFILE_TYPE_REDIS) {
SCMutexLock(&file_ctx->fp_mutex); SCMutexLock(&file_ctx->fp_mutex);
LogFileWriteRedis(file_ctx, string, string_len); LogFileWriteRedis(file_ctx, (const char *)MEMBUFFER_BUFFER(buffer),
MEMBUFFER_OFFSET(buffer));
SCMutexUnlock(&file_ctx->fp_mutex); SCMutexUnlock(&file_ctx->fp_mutex);
} }
#endif #endif

@ -130,7 +130,7 @@ typedef struct LogFileCtx_ {
LogFileCtx *LogFileNewCtx(void); LogFileCtx *LogFileNewCtx(void);
int LogFileFreeCtx(LogFileCtx *); int LogFileFreeCtx(LogFileCtx *);
int LogFileWrite(LogFileCtx *file_ctx, MemBuffer *buffer, char *string, size_t string_len); int LogFileWrite(LogFileCtx *file_ctx, MemBuffer *buffer);
int SCConfLogOpenGeneric(ConfNode *conf, LogFileCtx *, const char *, int); int SCConfLogOpenGeneric(ConfNode *conf, LogFileCtx *, const char *, int);
int SCConfLogOpenRedis(ConfNode *conf, LogFileCtx *log_ctx); int SCConfLogOpenRedis(ConfNode *conf, LogFileCtx *log_ctx);

Loading…
Cancel
Save