LOGIF and skygw_log_write removed.

All places where LOGIF and skygw_log_write were used have been
updated to use the new logging macros instead. Consequently,
they can now be removed.
This commit is contained in:
Johan Wikman
2015-11-18 15:08:50 +02:00
parent ee7793312b
commit 0345f3622d
4 changed files with 93 additions and 116 deletions

View File

@ -2208,13 +2208,11 @@ static bool thr_flush_file(logmanager_t *lm, filewriter_t *fwr)
if (!succ) if (!succ)
{ {
LOGIF(LE, (skygw_log_write( MXS_ERROR("Log rotation failed. "
LOGFILE_ERROR, "Creating replacement file %s "
"Error : Log rotation failed. " "failed. Continuing "
"Creating replacement file %s " "logging to existing file.",
"failed. Continuing " lf->lf_full_file_name);
"logging to existing file.",
lf->lf_full_file_name)));
} }
return true; return true;
} }

View File

@ -96,15 +96,6 @@ extern __thread log_info_t tls_log_info;
// TODO: Add this at a later stage. // TODO: Add this at a later stage.
#define MXS_LOG_PRIORITY_IS_ENABLED(priority) false #define MXS_LOG_PRIORITY_IS_ENABLED(priority) false
/**
* Execute the given command if specified log is enabled in general or
* if the log is enabled for the current session.
*/
#define LOGIF(id,cmd) if (LOG_IS_ENABLED(id)) \
{ \
cmd; \
}
/** /**
* LOG_AUGMENT_WITH_FUNCTION Each logged line is suffixed with [function-name]. * LOG_AUGMENT_WITH_FUNCTION Each logged line is suffixed with [function-name].
*/ */
@ -130,23 +121,15 @@ void mxs_log_set_augmentation(int bits);
int mxs_log_message(int priority, int mxs_log_message(int priority,
const char* file, int line, const char* function, const char* file, int line, const char* function,
const char* format, ...) __attribute__((format(printf, 5, 6))); const char* format, ...) __attribute__((format(printf, 5, 6)));
inline int mxs_log_id_to_priority(logfile_id_t id)
{
if (id & LOGFILE_ERROR) return LOG_ERR;
if (id & LOGFILE_MESSAGE) return LOG_NOTICE;
if (id & LOGFILE_TRACE) return LOG_INFO;
if (id & LOGFILE_DEBUG) return LOG_DEBUG;
return LOG_ERR;
}
#define skygw_log_write(id, format, ...)\
mxs_log_message(mxs_log_id_to_priority(id), __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
#define skygw_log_write_flush(id, format, ...) skygw_log_write(id, format, ##__VA_ARGS__)
/** /**
* Helper, not to be called directly. * Log an error, warning, notice, info, or debug message.
*
* @param priority One of the syslog constants (LOG_ERR, LOG_WARNING, ...)
* @param format The printf format of the message.
* @param ... Arguments, depending on the format.
*
* NOTE: Should typically not be called directly. Use some of the
* MXS_ERROR, MXS_WARNING, etc. macros instead.
*/ */
#define MXS_LOG_MESSAGE(priority, format, ...)\ #define MXS_LOG_MESSAGE(priority, format, ...)\
mxs_log_message(priority, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__) mxs_log_message(priority, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)

View File

@ -162,27 +162,26 @@ int main(int argc, char* argv[])
t = time(NULL); t = time(NULL);
tm = *(localtime(&t)); tm = *(localtime(&t));
err = skygw_log_write_flush(LOGFILE_ERROR, err = MXS_ERROR("%04d %02d/%02d %02d.%02d.%02d",
"%04d %02d/%02d %02d.%02d.%02d", tm.tm_year+1900,
tm.tm_year+1900, tm.tm_mon+1,
tm.tm_mon+1, tm.tm_mday,
tm.tm_mday, tm.tm_hour,
tm.tm_hour, tm.tm_min,
tm.tm_min, tm.tm_sec);
tm.tm_sec);
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("First write with flush."); logstr = ("First write with flush.");
err = skygw_log_write_flush(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
logstr = ("Second write with flush."); logstr = ("Second write with flush.");
err = skygw_log_write_flush(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
logstr = ("Third write, no flush."); logstr = ("Third write, no flush.");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
logstr = ("Fourth write, no flush. Next flush only."); logstr = ("Fourth write, no flush. Next flush only.");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
err = mxs_log_flush(); err = mxs_log_flush();
@ -190,57 +189,57 @@ int main(int argc, char* argv[])
#if !defined(SS_DEBUG) #if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
#endif #endif
err = skygw_log_write(LOGFILE_TRACE, logstr, "TraceyTracey", 3, 7); err = MXS_INFO(logstr, "TraceyTracey", 3, 7);
mxs_log_flush(); mxs_log_flush();
#if !defined(SS_DEBUG) #if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
#endif #endif
logstr = "My name is Tracey Tracey 47 years and 7 months."; logstr = "My name is Tracey Tracey 47 years and 7 months.";
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
#if !defined(SS_DEBUG) #if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
#endif #endif
logstr = "My name is Stacey %s"; logstr = "My name is Stacey %s";
err = skygw_log_write_flush(LOGFILE_TRACE, logstr, " "); err = MXS_INFO(logstr, " ");
mxs_log_finish(); mxs_log_finish();
#if !defined(SS_DEBUG) #if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
#endif #endif
logstr = "My name is Philip"; logstr = "My name is Philip";
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
#if !defined(SS_DEBUG) #if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
#endif #endif
logstr = "Philip."; logstr = "Philip.";
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
#if !defined(SS_DEBUG) #if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
#endif #endif
logstr = "Ph%dlip."; logstr = "Ph%dlip.";
err = skygw_log_write(LOGFILE_TRACE, logstr, 1); err = MXS_INFO(logstr, 1);
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("A terrible error has occurred!"); logstr = ("A terrible error has occurred!");
err = skygw_log_write_flush(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
logstr = ("Hi, how are you?"); logstr = ("Hi, how are you?");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
logstr = ("I'm doing fine!"); logstr = ("I'm doing fine!");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
logstr = ("Rather more surprising, at least at first sight, is the fact that a reference to " logstr = ("Rather more surprising, at least at first sight, is the fact that a reference to "
"a[i] can also be written as *(a+i). In evaluating a[i], C converts it to *(a+i) " "a[i] can also be written as *(a+i). In evaluating a[i], C converts it to *(a+i) "
"immediately; the two forms are equivalent. Applying the operators & to both parts " "immediately; the two forms are equivalent. Applying the operators & to both parts "
"of this equivalence, it follows that &a[i] and a+i are also identical: a+i is the " "of this equivalence, it follows that &a[i] and a+i are also identical: a+i is the "
"address of the i-th element beyond a."); "address of the i-th element beyond a.");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
logstr = ("I was wondering, you know, it has been such a lovely weather whole morning and I " 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 " "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, we could " "with us. Just me and my mom - and you, of course. Then, if you wish, we could "
"listen to the radio and keep company for our little Steven, my mom's cat, you know."); "listen to the radio and keep company for our little Steven, my mom's cat, you know.");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
mxs_log_finish(); mxs_log_finish();
#if defined(TEST1) #if defined(TEST1)
@ -369,60 +368,60 @@ int main(int argc, char* argv[])
ss_dassert(succp); ss_dassert(succp);
logstr = ("\tTEST 3 - test enabling and disabling logs."); logstr = ("\tTEST 3 - test enabling and disabling logs.");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
skygw_log_disable(LOGFILE_TRACE); skygw_log_disable(LOGFILE_TRACE);
logstr = ("1.\tWrite once to ERROR and twice to MESSAGE log."); logstr = ("1.\tWrite once to ERROR and twice to MESSAGE log.");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
logstr = ("2.\tWrite to once to ERROR, twice to MESSAGE and " logstr = ("2.\tWrite to once to ERROR, twice to MESSAGE and "
"three times to TRACE log."); "three times to TRACE log.");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
skygw_log_disable(LOGFILE_ERROR); skygw_log_disable(LOGFILE_ERROR);
logstr = ("3.\tWrite to once to MESSAGE and twice to TRACE log."); logstr = ("3.\tWrite to once to MESSAGE and twice to TRACE log.");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
skygw_log_disable(LOGFILE_MESSAGE); skygw_log_disable(LOGFILE_MESSAGE);
skygw_log_disable(LOGFILE_TRACE); skygw_log_disable(LOGFILE_TRACE);
logstr = ("4.\tWrite to none."); logstr = ("4.\tWrite to none.");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
skygw_log_enable(LOGFILE_ERROR); skygw_log_enable(LOGFILE_ERROR);
skygw_log_enable(LOGFILE_MESSAGE); skygw_log_enable(LOGFILE_MESSAGE);
logstr = ("4.\tWrite once to ERROR and twice to MESSAGE log."); logstr = ("4.\tWrite once to ERROR and twice to MESSAGE log.");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
mxs_log_finish(); mxs_log_finish();
@ -436,32 +435,32 @@ int main(int argc, char* argv[])
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
#endif #endif
logstr = ("\tTEST 4 - test spreading logs down to other logs."); logstr = ("\tTEST 4 - test spreading logs down to other logs.");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
logstr = ("1.\tWrite to ERROR and thus also to MESSAGE and TRACE logs."); logstr = ("1.\tWrite to ERROR and thus also to MESSAGE and TRACE logs.");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
logstr = ("2.\tWrite to MESSAGE and thus to TRACE logs."); logstr = ("2.\tWrite to MESSAGE and thus to TRACE logs.");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
logstr = ("3.\tWrite to TRACE log only."); logstr = ("3.\tWrite to TRACE log only.");
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
skygw_log_disable(LOGFILE_MESSAGE); skygw_log_disable(LOGFILE_MESSAGE);
logstr = ("4.\tWrite to ERROR and thus also to TRACE log. " logstr = ("4.\tWrite to ERROR and thus also to TRACE log. "
"MESSAGE is disabled."); "MESSAGE is disabled.");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
logstr = ("5.\tThis should not appear anywhere since MESSAGE " logstr = ("5.\tThis should not appear anywhere since MESSAGE "
"is disabled."); "is disabled.");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
mxs_log_finish(); mxs_log_finish();
@ -472,51 +471,48 @@ int main(int argc, char* argv[])
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
#endif #endif
logstr = ("6.\tWrite to ERROR and thus also to MESSAGE and TRACE logs."); logstr = ("6.\tWrite to ERROR and thus also to MESSAGE and TRACE logs.");
err = skygw_log_write_flush(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
logstr = ("7.\tWrite to MESSAGE and thus to TRACE logs."); logstr = ("7.\tWrite to MESSAGE and thus to TRACE logs.");
err = skygw_log_write_flush(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
logstr = ("8.\tWrite to TRACE log only."); logstr = ("8.\tWrite to TRACE log only.");
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
err = skygw_log_write_flush(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
skygw_log_disable(LOGFILE_MESSAGE); skygw_log_disable(LOGFILE_MESSAGE);
logstr = ("9.\tWrite to ERROR and thus also to TRACE log. " logstr = ("9.\tWrite to ERROR and thus also to TRACE log. "
"MESSAGE is disabled"); "MESSAGE is disabled");
err = skygw_log_write_flush(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
logstr = ("10.\tThis should not appear anywhere since MESSAGE is " logstr = ("10.\tThis should not appear anywhere since MESSAGE is "
"disabled."); "disabled.");
err = skygw_log_write_flush(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
ss_dassert(err == 0); ss_dassert(err == 0);
skygw_log_enable(LOGFILE_MESSAGE); skygw_log_enable(LOGFILE_MESSAGE);
err = skygw_log_write(LOGFILE_ERROR, err = MXS_ERROR("11.\tWrite to all logs some formattings : "
"11.\tWrite to all logs some formattings : " "%d %s %d",
"%d %s %d", (int)3,
(int)3, "foo",
"foo", (int)3);
(int)3); err = MXS_ERROR("12.\tWrite to MESSAGE and TRACE log some "
err = skygw_log_write(LOGFILE_MESSAGE, "formattings "
"12.\tWrite to MESSAGE and TRACE log some " ": %d %s %d",
"formattings " (int)3,
": %d %s %d", "foo",
(int)3, (int)3);
"foo", err = MXS_ERROR("13.\tWrite to TRACE log some formattings "
(int)3); ": %d %s %d",
err = skygw_log_write(LOGFILE_TRACE, (int)3,
"13.\tWrite to TRACE log some formattings " "foo",
": %d %s %d", (int)3);
(int)3,
"foo",
(int)3);
ss_dassert(err == 0); ss_dassert(err == 0);
@ -542,7 +538,7 @@ static void* thr_run(void* data)
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
mxs_log_flush(); mxs_log_flush();
logstr = ("Hi, how are you?"); logstr = ("Hi, how are you?");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
if (err != 0) if (err != 0)
{ {
@ -561,10 +557,10 @@ static void* thr_run(void* data)
TEST_ERROR("Error, log write failed."); TEST_ERROR("Error, log write failed.");
} }
ss_dassert(err == 0); ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("Testing. One, two, three\n"); logstr = ("Testing. One, two, three\n");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
if (err != 0) if (err != 0)
{ {
TEST_ERROR("Error, log write failed."); TEST_ERROR("Error, log write failed.");
@ -578,7 +574,7 @@ static void* thr_run(void* data)
#if !defined(SS_DEBUG) #if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
#endif #endif
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
if (err != 0) if (err != 0)
{ {
TEST_ERROR("Error, log write failed."); TEST_ERROR("Error, log write failed.");
@ -591,7 +587,7 @@ static void* thr_run(void* data)
"immediately; the two forms are equivalent. Applying the operatos & to both parts " "immediately; the two forms are equivalent. Applying the operatos & to both parts "
"of this equivalence, it follows that &a[i] and a+i are also identical: a+i is the " "of this equivalence, it follows that &a[i] and a+i are also identical: a+i is the "
"address of the i-th element beyond a."); "address of the i-th element beyond a.");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
if (err != 0) if (err != 0)
{ {
TEST_ERROR("Error, log write failed."); TEST_ERROR("Error, log write failed.");
@ -603,7 +599,7 @@ static void* thr_run(void* data)
mxs_log_finish(); mxs_log_finish();
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("..and you?"); logstr = ("..and you?");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
if (err != 0) if (err != 0)
{ {
TEST_ERROR("Error, log write failed."); TEST_ERROR("Error, log write failed.");
@ -615,7 +611,7 @@ static void* thr_run(void* data)
#if !defined(SS_DEBUG) #if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
#endif #endif
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
if (err != 0) if (err != 0)
{ {
TEST_ERROR("Error, log write failed."); TEST_ERROR("Error, log write failed.");
@ -627,7 +623,7 @@ static void* thr_run(void* data)
"immediately; the two forms are equivalent. Applying the operatos & to both parts " "immediately; the two forms are equivalent. Applying the operatos & to both parts "
"of this equivalence, it follows that &a[i] and a+i are also identical: a+i is the " "of this equivalence, it follows that &a[i] and a+i are also identical: a+i is the "
"address of the i-th element beyond a."); "address of the i-th element beyond a.");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
if (err != 0) if (err != 0)
{ {
TEST_ERROR("Error, log write failed."); TEST_ERROR("Error, log write failed.");
@ -635,7 +631,7 @@ static void* thr_run(void* data)
ss_dassert(err == 0); ss_dassert(err == 0);
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("..... and you too?"); logstr = ("..... and you too?");
err = skygw_log_write(LOGFILE_MESSAGE, "%s", logstr); err = MXS_NOTICE("%s", logstr);
if (err != 0) if (err != 0)
{ {
TEST_ERROR("Error, log write failed."); TEST_ERROR("Error, log write failed.");
@ -651,7 +647,7 @@ static void* thr_run(void* data)
#if !defined(SS_DEBUG) #if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE); skygw_log_enable(LOGFILE_TRACE);
#endif #endif
err = skygw_log_write(LOGFILE_TRACE, "%s", logstr); err = MXS_INFO("%s", logstr);
if (err != 0) if (err != 0)
{ {
TEST_ERROR("Error, log write failed."); TEST_ERROR("Error, log write failed.");
@ -660,7 +656,7 @@ static void* thr_run(void* data)
mxs_log_finish(); mxs_log_finish();
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("Testing. One, two, three, four\n"); logstr = ("Testing. One, two, three, four\n");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
if (err != 0) if (err != 0)
{ {
TEST_ERROR("Error, log write failed."); TEST_ERROR("Error, log write failed.");
@ -669,7 +665,7 @@ static void* thr_run(void* data)
mxs_log_finish(); mxs_log_finish();
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("Testing. One, two, three, .. where was I?\n"); logstr = ("Testing. One, two, three, .. where was I?\n");
err = skygw_log_write(LOGFILE_ERROR, "%s", logstr); err = MXS_ERROR("%s", logstr);
if (err != 0) if (err != 0)
{ {
TEST_ERROR("Error, log write failed."); TEST_ERROR("Error, log write failed.");
@ -726,7 +722,7 @@ static void* thr_run_morelog(void* data)
for (i = 0; i < NITER; i++) for (i = 0; i < NITER; i++)
{ {
char* str = logs[rand() % nmsg]; char* str = logs[rand() % nmsg];
err = skygw_log_write((logfile_id_t)(rand()%(LOGFILE_LAST+1)), err = MXS_LOG_MESSAGE((int)(rand() % (LOG_DEBUG+1)),
"%s - iteration # %d", "%s - iteration # %d",
str, str,
i); i);

View File

@ -124,11 +124,11 @@ int main(int argc, char** argv)
memset(message + block_size - 1, '\0', 1); memset(message + block_size - 1, '\0', 1);
if (interval > 0 && i % interval == 0) if (interval > 0 && i % interval == 0)
{ {
err = skygw_log_write_flush(LOGFILE_ERROR, "%s", message); err = MXS_ERROR("%s", message);
} }
else else
{ {
err = skygw_log_write(LOGFILE_ERROR, "%s", message); err = MXS_ERROR("%s", message);
} }
if (err) if (err)
{ {