Log: skygw_log_flush replaced with mxs_log_flush.
skygw_log_flush replaced with mxs_log_flush and skygw_log_sync_all with mxs_log_flush_sync.
This commit is contained in:
@ -1308,38 +1308,6 @@ static int log_write(int priority,
|
||||
return rv;
|
||||
}
|
||||
|
||||
int skygw_log_flush(logfile_id_t id)
|
||||
{
|
||||
int err = -1;
|
||||
|
||||
if (id == LOGFILE_ERROR)
|
||||
{
|
||||
if (logmanager_register(false))
|
||||
{
|
||||
CHK_LOGMANAGER(lm);
|
||||
|
||||
logfile_t *lf = logmanager_get_logfile(lm);
|
||||
CHK_LOGFILE(lf);
|
||||
|
||||
logfile_flush(lf);
|
||||
err = 0;
|
||||
|
||||
logmanager_unregister();
|
||||
}
|
||||
else
|
||||
{
|
||||
ss_dfprintf(stderr, "Can't register to logmanager, flushing failed.\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We'll pretend everything went ok.
|
||||
err = 0;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* @node Register as a logging client to logmanager.
|
||||
*
|
||||
@ -2592,26 +2560,6 @@ void flushall_logfiles(bool flush)
|
||||
simple_mutex_unlock(&lm->lm_mutex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush all log files synchronously
|
||||
*/
|
||||
void skygw_log_sync_all(void)
|
||||
{
|
||||
if (!log_config.use_stdout)
|
||||
{
|
||||
skygw_log_write(LOGFILE_TRACE,"Starting log flushing to disk.");
|
||||
}
|
||||
|
||||
/** If initialization of the log manager has not been done, lm pointer can be
|
||||
* NULL. */
|
||||
if (lm)
|
||||
{
|
||||
flushall_logfiles(true);
|
||||
skygw_message_send(lm->lm_logmes);
|
||||
skygw_message_wait(lm->lm_clientmes);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle high precision logging
|
||||
* @param val 0 for disabled, 1 for enabled
|
||||
@ -2652,7 +2600,63 @@ void logmanager_enable_maxscalelog(int val)
|
||||
*/
|
||||
int mxs_log_flush()
|
||||
{
|
||||
return skygw_log_flush(LOGFILE_ERROR);
|
||||
int err = -1;
|
||||
|
||||
if (logmanager_register(false))
|
||||
{
|
||||
CHK_LOGMANAGER(lm);
|
||||
|
||||
logfile_t *lf = logmanager_get_logfile(lm);
|
||||
CHK_LOGFILE(lf);
|
||||
|
||||
logfile_flush(lf);
|
||||
err = 0;
|
||||
|
||||
logmanager_unregister();
|
||||
}
|
||||
else
|
||||
{
|
||||
ss_dfprintf(stderr, "Can't register to logmanager, flushing failed.\n");
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicitly ensure that all pending log messages are flushed.
|
||||
*
|
||||
* @return 0 if the flushing was successfully performed, otherwise -1.
|
||||
*
|
||||
* When the function returns 0, the flushing has been initiated and the
|
||||
* flushing thread has indicated that the operation has been performed.
|
||||
* However, 0 will be returned also in the case that the flushing thread
|
||||
* for, whatever reason, failed to actually flush the log.
|
||||
*/
|
||||
int mxs_log_flush_sync(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
if (!log_config.use_stdout)
|
||||
{
|
||||
MXS_INFO("Starting log flushing to disk.");
|
||||
}
|
||||
|
||||
/** If initialization of the log manager has not been done, lm pointer can be
|
||||
* NULL. */
|
||||
// TODO: Why is logmanager_register() not called here?
|
||||
if (lm)
|
||||
{
|
||||
flushall_logfiles(true);
|
||||
err = skygw_message_send(lm->lm_logmes);
|
||||
|
||||
if (!err)
|
||||
{
|
||||
// TODO: Add error handling to skygw_message_wait. Now void.
|
||||
skygw_message_wait(lm->lm_clientmes);
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -142,7 +142,9 @@ bool mxs_log_init(const char* ident, const char* logdir, log_target_t target);
|
||||
void mxs_log_finish(void);
|
||||
|
||||
int mxs_log_flush();
|
||||
int mxs_log_flush_sync();
|
||||
int mxs_log_rotate();
|
||||
|
||||
int mxs_log_enable_priority(int priority);
|
||||
int mxs_log_disable_priority(int priority);
|
||||
|
||||
@ -150,14 +152,8 @@ int mxs_log_message(int priority,
|
||||
const char* file, int line, const char* function,
|
||||
const char* format, ...);
|
||||
|
||||
/**
|
||||
* free private write buffer list
|
||||
*/
|
||||
int skygw_log_flush(logfile_id_t id);
|
||||
void skygw_log_sync_all(void);
|
||||
int skygw_log_enable(logfile_id_t id);
|
||||
int skygw_log_disable(logfile_id_t id);
|
||||
void skygw_log_sync_all(void);
|
||||
void skygw_set_highp(int);
|
||||
void logmanager_enable_syslog(int);
|
||||
void logmanager_enable_maxscalelog(int);
|
||||
|
@ -152,14 +152,14 @@ int main(int argc, char* argv[])
|
||||
logstr = ("Fourth write, no flush. Next flush only.");
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
|
||||
err = skygw_log_flush(LOGFILE_ERROR);
|
||||
err = mxs_log_flush();
|
||||
|
||||
logstr = "My name is %s %d years and %d months.";
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
#endif
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr, "TraceyTracey", 3, 7);
|
||||
skygw_log_flush(LOGFILE_TRACE);
|
||||
mxs_log_flush();
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
#endif
|
||||
@ -508,7 +508,7 @@ static void* thr_run(void* data)
|
||||
int err;
|
||||
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
skygw_log_flush(LOGFILE_MESSAGE);
|
||||
mxs_log_flush();
|
||||
logstr = ("Hi, how are you?");
|
||||
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
|
||||
|
||||
@ -518,8 +518,7 @@ static void* thr_run(void* data)
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
mxs_log_finish();
|
||||
skygw_log_flush(LOGFILE_TRACE);
|
||||
skygw_log_flush(LOGFILE_MESSAGE);
|
||||
mxs_log_flush();
|
||||
logstr = ("I was wondering, you know, it has been such a lovely weather whole morning and "
|
||||
"I thought that would you like to come to my place and have a little piece of "
|
||||
"cheese with us. Just me and my mom - and you, of course. Then, if you wish, "
|
||||
@ -541,7 +540,7 @@ static void* thr_run(void* data)
|
||||
ss_dassert(err == 0);
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
skygw_log_flush(LOGFILE_ERROR);
|
||||
mxs_log_flush();
|
||||
logstr = ("For automatic and register variables, it is done each time the function or block is entered.");
|
||||
|
||||
#if !defined(SS_DEBUG)
|
||||
@ -568,7 +567,7 @@ static void* thr_run(void* data)
|
||||
ss_dassert(err == 0);
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
mxs_log_finish();
|
||||
skygw_log_flush(LOGFILE_ERROR);
|
||||
mxs_log_flush();
|
||||
mxs_log_finish();
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
logstr = ("..and you?");
|
||||
@ -615,7 +614,7 @@ static void* thr_run(void* data)
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
#endif
|
||||
skygw_log_flush(LOGFILE_TRACE);
|
||||
mxs_log_flush();
|
||||
logstr = ("For automatic and register variables, it is done each time the function or block is entered.");
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
|
@ -107,7 +107,7 @@ int main(int argc, char** argv)
|
||||
nanosleep(&ts1, NULL);
|
||||
}
|
||||
|
||||
skygw_log_flush(LOGFILE_ERROR);
|
||||
mxs_log_flush();
|
||||
mxs_log_finish();
|
||||
free(message);
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user