suricata
|
#include "suricata-common.h"
#include "util-logopenfile.h"
#include "suricata.h"
#include "conf.h"
#include "output.h"
#include "util-byte.h"
#include "util-conf.h"
#include "util-path.h"
#include "util-time.h"
Go to the source code of this file.
Macros | |
#define | LOGFILE_NAME_MAX 255 |
Functions | |
bool | SCLogOpenThreadedFile (const char *log_path, const char *append, LogFileCtx *parent_ctx) |
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... | |
LogFileCtx * | LogFileNewCtx (void) |
LogFileNewCtx() Get a new LogFileCtx. More... | |
LogFileCtx * | LogFileEnsureExists (ThreadId thread_id, LogFileCtx *parent_ctx) |
LogFileEnsureExists() Ensure a log file context for the thread exists. More... | |
int | LogFileFreeCtx (LogFileCtx *lf_ctx) |
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory) More... | |
int | LogFileWrite (LogFileCtx *file_ctx, MemBuffer *buffer) |
File-like output for logging: regular files and sockets.
Definition in file util-logopenfile.c.
#define LOGFILE_NAME_MAX 255 |
Definition at line 48 of file util-logopenfile.c.
LogFileCtx* LogFileEnsureExists | ( | ThreadId | thread_id, |
LogFileCtx * | parent_ctx | ||
) |
LogFileEnsureExists() Ensure a log file context for the thread exists.
parent_ctx |
LogFileCtx | * pointer if successful; NULL otherwise |
Definition at line 709 of file util-logopenfile.c.
References LogThreadedFileCtx_::mutex, SCMutexLock, LogFileCtx_::threaded, and LogFileCtx_::threads.
Referenced by CreateEveThreadCtx(), and JsonLogThreadInit().
int LogFileFreeCtx | ( | LogFileCtx * | lf_ctx | ) |
LogFileFreeCtx() Destroy a LogFileCtx (Close the file and free memory)
lf_ctx | pointer to the OutputCtx |
int | 1 if successful, 0 if error |
Definition at line 868 of file util-logopenfile.c.
References LogThreadedFileCtx_::append, BUG_ON, LogFileCtx_::Close, SCEveFileType_::Deinit, LogFileCtx_::filename, LogFileTypeCtx_::filetype, LogFileCtx_::filetype, LogFileCtx_::fp, LogFileCtx_::fp_mutex, HashTableFree(), LogThreadedFileCtx_::ht, LogFileTypeCtx_::init_data, LOGFILE_TYPE_FILETYPE, LOGFILE_TYPE_REDIS, LogThreadedFileCtx_::mutex, OutputUnregisterFileRotationFlag(), LogFileCtx_::parent, LogFileCtx_::prefix, LogFileCtx_::prefix_len, LogFileCtx_::rotation_flag, SCFree, SCMutexDestroy, SCReturnInt, LogFileCtx_::sensor_name, LogFileTypeCtx_::thread_data, SCEveFileType_::ThreadDeinit, LogFileCtx_::threaded, LogFileCtx_::threads, and LogFileCtx_::type.
Referenced by AlertFastLogInitCtx(), LogHttpLogInitCtx(), and LogTcpDataLogInitCtx().
LogFileCtx* LogFileNewCtx | ( | void | ) |
LogFileNewCtx() Get a new LogFileCtx.
LogFileCtx | * pointer if successful, NULL if error |
Definition at line 659 of file util-logopenfile.c.
References SCCalloc, and LogFileCtx_::Write.
Referenced by AlertFastLogInitCtx(), LogHttpLogInitCtx(), LogTcpDataLogInitCtx(), and OutputJsonInitCtx().
int LogFileWrite | ( | LogFileCtx * | file_ctx, |
MemBuffer * | buffer | ||
) |
Definition at line 933 of file util-logopenfile.c.
References LogFileTypeCtx_::filetype, LogFileCtx_::filetype, LogFileCtx_::fp_mutex, LogFileTypeCtx_::init_data, LOGFILE_TYPE_FILE, LOGFILE_TYPE_FILETYPE, LOGFILE_TYPE_REDIS, LOGFILE_TYPE_UNIX_DGRAM, LOGFILE_TYPE_UNIX_STREAM, MEMBUFFER_BUFFER, MEMBUFFER_OFFSET, MemBufferWriteString(), SCMutexLock, SCMutexUnlock, LogFileTypeCtx_::thread_data, LogFileCtx_::type, LogFileCtx_::Write, and SCEveFileType_::Write.
Referenced by OutputJSONBuffer().
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
conf | ConfNode structure for the output section in question |
log_ctx | Log file context allocated by caller |
default_filename | Default name of file to open, if not specified in ConfNode |
rotate | Register the file for rotation in HUP. |
0 | on success |
-1 | on error |
Definition at line 452 of file util-logopenfile.c.
References ConfigGetLogDirectory(), ConfNodeLookupChild(), ConfNodeLookupChildValue(), ConfValIsFalse(), DEFAULT_LOG_FILETYPE, DEFAULT_LOG_MODE_APPEND, FatalError, LogFileCtx_::filemode, LogFileCtx_::flags, LogFileCtx_::fp, LogFileCtx_::is_regular, LogFileCtx_::is_sock, JSON_ESCAPE_SLASH, LogFileCtx_::json_flags, LOGFILE_ROTATE_INTERVAL, PathIsAbsolute(), LogFileCtx_::rotate_interval, LogFileCtx_::rotate_time, SCGetSecondsUntil(), SCLogError, SCParseTimeSizeString(), LogFileCtx_::sock_type, StringParseUint32(), and LogFileCtx_::threaded.
Referenced by AlertFastLogInitCtx(), LogHttpLogInitCtx(), and LogTcpDataLogInitCtx().
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 629 of file util-logopenfile.c.
References LogFileCtx_::filename, LogFileCtx_::fp, LogFileCtx_::is_regular, SCLogDebug, and SCLogWarning.
bool SCLogOpenThreadedFile | ( | const char * | log_path, |
const char * | append, | ||
LogFileCtx * | parent_ctx | ||
) |
Definition at line 359 of file util-logopenfile.c.
References HashTableInit(), LogThreadedFileCtx_::ht, SCCalloc, SCLogError, and LogFileCtx_::threads.