logger.c add new line with fprintf
parent
c20b7306b0
commit
3e47901340
18
src/logger.c
18
src/logger.c
|
|
@ -51,7 +51,7 @@ static int check_and_mk_log_dir(const char *base_path)
|
||||||
if (mkdir(data_path, 0755) != 0)
|
if (mkdir(data_path, 0755) != 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "mkdir \"%s\" fail, " \
|
fprintf(stderr, "mkdir \"%s\" fail, " \
|
||||||
"errno: %d, error info: %s", \
|
"errno: %d, error info: %s\n", \
|
||||||
data_path, errno, STRERROR(errno));
|
data_path, errno, STRERROR(errno));
|
||||||
return errno != 0 ? errno : EPERM;
|
return errno != 0 ? errno : EPERM;
|
||||||
}
|
}
|
||||||
|
|
@ -64,6 +64,8 @@ int log_init()
|
||||||
{
|
{
|
||||||
if (g_log_context.log_buff != NULL)
|
if (g_log_context.log_buff != NULL)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "file: "__FILE__", line: %d, "
|
||||||
|
"g_log_context already inited\n", __LINE__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -96,7 +98,7 @@ int log_init_ex(LogContext *pContext)
|
||||||
if (pContext->log_buff == NULL)
|
if (pContext->log_buff == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "malloc %d bytes fail, " \
|
fprintf(stderr, "malloc %d bytes fail, " \
|
||||||
"errno: %d, error info: %s", \
|
"errno: %d, error info: %s\n", \
|
||||||
LOG_BUFF_SIZE, errno, STRERROR(errno));
|
LOG_BUFF_SIZE, errno, STRERROR(errno));
|
||||||
return errno != 0 ? errno : ENOMEM;
|
return errno != 0 ? errno : ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
@ -761,7 +763,7 @@ static void log_gzip(LogContext *pContext)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
||||||
"create thread failed, " \
|
"create thread failed, " \
|
||||||
"errno: %d, error info: %s", \
|
"errno: %d, error info: %s\n", \
|
||||||
__LINE__, result, STRERROR(result));
|
__LINE__, result, STRERROR(result));
|
||||||
}
|
}
|
||||||
pthread_attr_destroy(&thread_attr);
|
pthread_attr_destroy(&thread_attr);
|
||||||
|
|
@ -888,7 +890,7 @@ static int log_fsync(LogContext *pContext, const bool bNeedLock)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
||||||
"call pthread_mutex_lock fail, " \
|
"call pthread_mutex_lock fail, " \
|
||||||
"errno: %d, error info: %s", \
|
"errno: %d, error info: %s\n", \
|
||||||
__LINE__, lock_res, STRERROR(lock_res));
|
__LINE__, lock_res, STRERROR(lock_res));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -924,7 +926,7 @@ static int log_fsync(LogContext *pContext, const bool bNeedLock)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
||||||
"call pthread_mutex_unlock fail, " \
|
"call pthread_mutex_unlock fail, " \
|
||||||
"errno: %d, error info: %s", \
|
"errno: %d, error info: %s\n", \
|
||||||
__LINE__, lock_res, STRERROR(lock_res));
|
__LINE__, lock_res, STRERROR(lock_res));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -961,14 +963,14 @@ static void doLogEx(LogContext *pContext, struct timeval *tv, \
|
||||||
{
|
{
|
||||||
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
||||||
"call pthread_mutex_lock fail, " \
|
"call pthread_mutex_lock fail, " \
|
||||||
"errno: %d, error info: %s", \
|
"errno: %d, error info: %s\n", \
|
||||||
__LINE__, result, STRERROR(result));
|
__LINE__, result, STRERROR(result));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text_len + 64 > LOG_BUFF_SIZE)
|
if (text_len + 64 > LOG_BUFF_SIZE)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
||||||
"log buff size: %d < log text length: %d ", \
|
"log buff size: %d < log text length: %d\n", \
|
||||||
__LINE__, LOG_BUFF_SIZE, text_len + 64);
|
__LINE__, LOG_BUFF_SIZE, text_len + 64);
|
||||||
if (bNeedLock)
|
if (bNeedLock)
|
||||||
{
|
{
|
||||||
|
|
@ -1021,7 +1023,7 @@ static void doLogEx(LogContext *pContext, struct timeval *tv, \
|
||||||
{
|
{
|
||||||
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
fprintf(stderr, "file: "__FILE__", line: %d, " \
|
||||||
"call pthread_mutex_unlock fail, " \
|
"call pthread_mutex_unlock fail, " \
|
||||||
"errno: %d, error info: %s", \
|
"errno: %d, error info: %s\n", \
|
||||||
__LINE__, result, STRERROR(result));
|
__LINE__, result, STRERROR(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue