提交 c790ac52 编写于 作者: Y yuqing

add function log_set_fd_flags

上级 ba60d108
Version 1.06 2014-08-26
Version 1.06 2014-08-27
* update source code from FastDFS V5.02
* add function short2buff and buff2short
* add object memory pool (fast_mblock.h and fast_mblock.c)
......@@ -25,6 +25,7 @@ Version 1.06 2014-08-26
* add function ioevent_remove
* add function log_reopen_ex
* extern function log_rotate
* add function log_set_fd_flags
Version 1.05 2012-07-08
* update source code from FastDFS V3.09
......
......@@ -106,7 +106,7 @@ int log_init_ex(LogContext *pContext)
static int log_open(LogContext *pContext)
{
if ((pContext->log_fd = open(pContext->log_filename, O_WRONLY | \
O_CREAT | O_APPEND, 0644)) < 0)
O_CREAT | O_APPEND | pContext->fd_flags, 0644)) < 0)
{
fprintf(stderr, "open log file \"%s\" to write fail, " \
"errno: %d, error info: %s\n", \
......@@ -234,6 +234,11 @@ void log_take_over_stdout_ex(LogContext *pContext)
pContext->take_over_stdout = true;
}
void log_set_fd_flags(LogContext *pContext, const int flags)
{
pContext->fd_flags = flags;
}
void log_destroy_ex(LogContext *pContext)
{
if (pContext->log_fd >= 0 && pContext->log_fd != STDERR_FILENO)
......
......@@ -81,6 +81,9 @@ typedef struct log_context
/* keep days for rotated log files */
int keep_days;
/* log fd flags */
int fd_flags;
/*
* log the header (title line) callback
* */
......@@ -197,6 +200,14 @@ void log_take_over_stderr_ex(LogContext *pContext);
*/
void log_take_over_stdout_ex(LogContext *pContext);
/** set log fd flags
* parameters:
* pContext: the log context
* flags: the fd flags
* return: none
*/
void log_set_fd_flags(LogContext *pContext, const int flags);
/** destroy function
* parameters:
* pContext: the log context
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册