add function log_set_fd_flags
parent
ba60d10858
commit
c790ac5208
3
HISTORY
3
HISTORY
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
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)
|
||||
|
|
|
|||
11
src/logger.h
11
src/logger.h
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue