util-logopenfile.h File Reference
#include "threads.h"
#include "conf.h"
#include "util-buffer.h"
#include "util-hash.h"
#include "suricata-plugin.h"
Include dependency graph for util-logopenfile.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  SyslogSetup_
struct  ThreadLogFileHashEntry
struct  LogThreadedFileCtx_
struct  LogFilePluginCtx_
struct  LogFileCtx_




typedef struct SyslogSetup_ SyslogSetup
typedef struct ThreadLogFileHashEntry ThreadLogFileHashEntry
typedef struct LogThreadedFileCtx_ LogThreadedFileCtx
typedef struct LogFilePluginCtx_ LogFilePluginCtx
typedef struct LogFileCtx_ LogFileCtx


enum  LogFileType {


LogFileCtxLogFileNewCtx (void)
 LogFileNewCtx() Get a new LogFileCtx. More...
int LogFileFreeCtx (LogFileCtx *)
 LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory) More...
int LogFileWrite (LogFileCtx *file_ctx, MemBuffer *buffer)
LogFileCtxLogFileEnsureExists (LogFileCtx *lf_ctx)
 LogFileEnsureExists() Ensure a log file context for the thread exists. More...
int SCConfLogOpenGeneric (ConfNode *conf, LogFileCtx *, const char *, int)
 open a generic output "log file", which may be a regular file or a socket More...
int SCConfLogReopen (LogFileCtx *)
 Reopen a regular log file with the side-affect of truncating it. More...
bool SCLogOpenThreadedFile (const char *log_path, const char *append, LogFileCtx *parent_ctx)

Detailed Description

Macro Definition Documentation



Definition at line 164 of file util-logopenfile.h.



Definition at line 167 of file util-logopenfile.h.

Typedef Documentation

◆ LogFileCtx

typedef struct LogFileCtx_ LogFileCtx

Global structure for Output Context

◆ LogFilePluginCtx

◆ LogThreadedFileCtx

◆ SyslogSetup

typedef struct SyslogSetup_ SyslogSetup

◆ ThreadLogFileHashEntry

Enumeration Type Documentation

◆ LogFileType


Definition at line 38 of file util-logopenfile.h.

Function Documentation

◆ LogFileEnsureExists()

LogFileCtx* LogFileEnsureExists ( LogFileCtx parent_ctx)

LogFileEnsureExists() Ensure a log file context for the thread exists.

Return values
LogFileCtx* pointer if successful; NULL otherwise

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

References LogThreadedFileCtx_::mutex, SCMutexLock, LogFileCtx_::threaded, and LogFileCtx_::threads.

Referenced by CreateEveThreadCtx(), and JsonLogThreadInit().

Here is the caller graph for this function:

◆ LogFileFreeCtx()

◆ LogFileNewCtx()

LogFileCtx* LogFileNewCtx ( void  )

LogFileNewCtx() Get a new LogFileCtx.

Return values
LogFileCtx* pointer if successful, NULL if error

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

References SCCalloc, and LogFileCtx_::Write.

Referenced by AlertFastLogInitCtx(), LogHttpLogInitCtx(), LogTcpDataLogInitCtx(), and OutputJsonInitCtx().

Here is the caller graph for this function:

◆ LogFileWrite()

◆ SCConfLogOpenGeneric()

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

confConfNode structure for the output section in question
log_ctxLog file context allocated by caller
default_filenameDefault name of file to open, if not specified in ConfNode
rotateRegister the file for rotation in HUP.
Return values
0on success
-1on error

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

Referenced by AlertFastLogInitCtx(), LogHttpLogInitCtx(), and LogTcpDataLogInitCtx().

Here is the caller graph for this function:

◆ SCConfLogReopen()

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 630 of file util-logopenfile.c.

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

◆ SCLogOpenThreadedFile()

bool SCLogOpenThreadedFile ( const char *  log_path,
const char *  append,
LogFileCtx parent_ctx 

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