Removed duplicate code.
This commit is contained in:
parent
f2c5df703b
commit
ddcfe03c15
@ -288,12 +288,6 @@ static void logmanager_unregister(void);
|
||||
static bool logmanager_init_nomutex(int argc, char* argv[]);
|
||||
static void logmanager_done_nomutex(void);
|
||||
|
||||
enum log_flush
|
||||
{
|
||||
LOG_FLUSH_NO = 0,
|
||||
LOG_FLUSH_YES = 1
|
||||
};
|
||||
|
||||
enum log_spread_down
|
||||
{
|
||||
LOG_SPREAD_DOWN_NO = 0,
|
||||
@ -1558,50 +1552,12 @@ static int log_write(logfile_id_t id,
|
||||
return rv;
|
||||
}
|
||||
|
||||
int skygw_log_write_context_flush(logfile_id_t id,
|
||||
const char* file,
|
||||
int line,
|
||||
const char* function,
|
||||
const char* str,
|
||||
...)
|
||||
{
|
||||
int err = 0;
|
||||
va_list valist;
|
||||
|
||||
/**
|
||||
* Find out the length of log string (to be formatted str).
|
||||
*/
|
||||
va_start(valist, str);
|
||||
int len = vsnprintf(NULL, 0, str, valist);
|
||||
va_end(valist);
|
||||
|
||||
if (len >= 0)
|
||||
{
|
||||
char message[len + 1];
|
||||
|
||||
va_start(valist, str);
|
||||
int len2 = vsnprintf(message, sizeof(message), str, valist);
|
||||
va_end(valist);
|
||||
assert(len2 == len);
|
||||
|
||||
err = log_write(id, file, line, function, len2, message, LOG_FLUSH_YES);
|
||||
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr, "skygw_log_write_flush failed.\n");
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int skygw_log_write_context(logfile_id_t id,
|
||||
const char* file,
|
||||
int line,
|
||||
const char* function,
|
||||
const char* str,
|
||||
int skygw_log_write_context(logfile_id_t id,
|
||||
enum log_flush flush,
|
||||
const char* file,
|
||||
int line,
|
||||
const char* function,
|
||||
const char* str,
|
||||
...)
|
||||
{
|
||||
int err = 0;
|
||||
@ -1627,7 +1583,7 @@ int skygw_log_write_context(logfile_id_t id,
|
||||
vsnprintf(message, sizeof(message), str, valist);
|
||||
va_end(valist);
|
||||
|
||||
err = log_write(id, file, line, function, len, message, LOG_FLUSH_NO);
|
||||
err = log_write(id, file, line, function, len, message, flush);
|
||||
|
||||
if (err != 0)
|
||||
{
|
||||
|
@ -124,6 +124,16 @@ typedef enum
|
||||
LOG_AUGMENTATION_MASK = (LOG_AUGMENT_WITH_FUNCTION)
|
||||
} log_augmentation_t;
|
||||
|
||||
/**
|
||||
* LOG_FLUSH_NO Do not flush after writing.
|
||||
* LOG_FLUSH_YES Flush after writing.
|
||||
*/
|
||||
enum log_flush
|
||||
{
|
||||
LOG_FLUSH_NO = 0,
|
||||
LOG_FLUSH_YES = 1
|
||||
};
|
||||
|
||||
EXTERN_C_BLOCK_BEGIN
|
||||
|
||||
bool skygw_logmanager_init(int argc, char* argv[]);
|
||||
@ -135,14 +145,12 @@ void skygw_logmanager_exit(void);
|
||||
*/
|
||||
void skygw_log_done(void);
|
||||
int skygw_log_write_context(logfile_id_t id,
|
||||
enum log_flush flush,
|
||||
const char* file, int line, const char* function,
|
||||
const char* format, ...);
|
||||
int skygw_log_flush(logfile_id_t id);
|
||||
void skygw_log_sync_all(void);
|
||||
int skygw_log_rotate(logfile_id_t id);
|
||||
int skygw_log_write_context_flush(logfile_id_t id,
|
||||
const char* file, int line, const char* function,
|
||||
const char* format, ...);
|
||||
int skygw_log_enable(logfile_id_t id);
|
||||
int skygw_log_disable(logfile_id_t id);
|
||||
void skygw_log_sync_all(void);
|
||||
@ -151,10 +159,10 @@ void logmanager_enable_syslog(int);
|
||||
void logmanager_enable_maxscalelog(int);
|
||||
|
||||
#define skygw_log_write(id, format, ...)\
|
||||
skygw_log_write_context(id, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
|
||||
skygw_log_write_context(id, LOG_FLUSH_NO, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
|
||||
|
||||
#define skygw_log_write_flush(id, format, ...)\
|
||||
skygw_log_write_context_flush(id, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
|
||||
skygw_log_write_context(id, LOG_FLUSH_YES, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* What augmentation if any should a logged message be augmented with.
|
||||
|
Loading…
x
Reference in New Issue
Block a user