suricata
util-logopenfile.c File Reference
#include "suricata-common.h"
#include "tm-modules.h"
#include "conf.h"
#include "output.h"
#include "util-byte.h"
#include "util-path.h"
#include "util-logopenfile.h"
Include dependency graph for util-logopenfile.c:

Go to the source code of this file.

Functions

int SCConfLogOpenGeneric (ConfNode *conf, LogFileCtx *log_ctx, const char *default_filename, int rotate)
 open a generic output "log file", which may be a regular file or a socket More...
 
int SCConfLogReopen (LogFileCtx *log_ctx)
 Reopen a regular log file with the side-affect of truncating it. More...
 
LogFileCtxLogFileNewCtx (void)
 LogFileNewCtx() Get a new LogFileCtx. More...
 
int LogFileFreeCtx (LogFileCtx *lf_ctx)
 LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory) More...
 
int LogFileWrite (LogFileCtx *file_ctx, MemBuffer *buffer)
 

Detailed Description

Author
Mike Pomraning mpomr.nosp@m.anin.nosp@m.g@qua.nosp@m.lys..nosp@m.com

File-like output for logging: regular files and sockets.

Definition in file util-logopenfile.c.

Function Documentation

int LogFileFreeCtx ( LogFileCtx lf_ctx)

LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)

Parameters
motcxpointer to the OutputCtx
Return values
int1 if succesful, 0 if error

Definition at line 541 of file util-logopenfile.c.

References LogFileCtx_::Close, LogFileCtx_::filename, LogFileCtx_::fp, LogFileCtx_::fp_mutex, OutputUnregisterFileRotationFlag(), LogFileCtx_::prefix, LogFileCtx_::prefix_len, LogFileCtx_::rotation_flag, SCFree, SCMutexDestroy, SCMutexLock, SCMutexUnlock, SCReturnInt, and LogFileCtx_::sensor_name.

Referenced by AlertFastLogInitCtx(), LogHttpLogInitCtx(), LogStatsLogThreadDeinit(), LogTcpDataLogInitCtx(), OutputJsonRegister(), TLSGetIPInformations(), and Unified2AlertInitCtx().

Here is the call graph for this function:

Here is the caller graph for this function:

LogFileCtx* LogFileNewCtx ( void  )

LogFileNewCtx() Get a new LogFileCtx.

Return values
LogFileCtx* pointer if succesful, NULL if error

Definition at line 519 of file util-logopenfile.c.

References LogFileCtx_::Close, LogFileCtx_::fp_mutex, SCMalloc, SCMutexInit, and LogFileCtx_::Write.

Referenced by AlertFastLogInitCtx(), LogHttpLogInitCtx(), LogStatsLogThreadDeinit(), LogTcpDataLogInitCtx(), OutputJsonRegister(), TLSGetIPInformations(), and Unified2AlertInitCtx().

Here is the caller graph for this function:

int SCConfLogOpenGeneric ( ConfNode conf,
LogFileCtx log_ctx,
const char *  default_filename,
int  rotate 
)
int SCConfLogReopen ( LogFileCtx log_ctx)

Reopen a regular log file with the side-affect of truncating it.

This is useful to clear the log file and start a new one, or to re-open the file after its been moved by something external (eg. logrotate).

Definition at line 488 of file util-logopenfile.c.

References LogFileCtx_::filemode, LogFileCtx_::filename, LogFileCtx_::fp, LogFileCtx_::is_regular, SC_ERR_INVALID_ARGUMENT, SCLogDebug, and SCLogWarning.