Remove all traces of logfile_t

The earlier log file based approach for enabling and disabling
messages has now been completely replaced with the syslog priority
based approach.

Similarly as with log files before it is now possible to enable
and disable a log priority for a particular session, even though
it apparently has not been used much.

The local test-programs of the logging has got minimal attention
only to make them compile. They should get an overhaul as they did
not work before either.
This commit is contained in:
Johan Wikman
2015-11-23 19:02:46 +02:00
parent 910ddb99fd
commit a8535f42af
15 changed files with 334 additions and 489 deletions

View File

@ -62,36 +62,14 @@ const int N_THR = 4;
#define TEST_ERROR(msg)\
do { fprintf(stderr, "[%s:%d]: %s\n", basename(__FILE__), __LINE__, msg); } while (false)
static logfile_id_t id_to_priority(logfile_id_t id)
static void skygw_log_enable(int priority)
{
switch (id)
{
case LOGFILE_ERROR:
return LOG_ERR;
case LOGFILE_MESSAGE:
return LOG_NOTICE;
case LOGFILE_TRACE:
return LOG_INFO;
case LOGFILE_DEBUG:
return LOG_DEBUG;
default:
assert(!true);
return LOG_ERR;
}
mxs_log_set_priority_enabled(priority, true);
}
static void skygw_log_enable(logfile_id_t id)
static void skygw_log_disable(int priority)
{
mxs_log_set_priority_enabled(id_to_priority(id), true);
}
static void skygw_log_disable(logfile_id_t id)
{
mxs_log_set_priority_enabled(id_to_priority(id), false);
mxs_log_set_priority_enabled(priority, false);
}
int main(int argc, char* argv[])
@ -187,33 +165,33 @@ int main(int argc, char* argv[])
logstr = "My name is %s %d years and %d months.";
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
#endif
err = MXS_INFO(logstr, "TraceyTracey", 3, 7);
mxs_log_flush();
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
#endif
logstr = "My name is Tracey Tracey 47 years and 7 months.";
err = MXS_INFO("%s", logstr);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
#endif
logstr = "My name is Stacey %s";
err = MXS_INFO(logstr, " ");
mxs_log_finish();
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
#endif
logstr = "My name is Philip";
err = MXS_INFO("%s", logstr);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
#endif
logstr = "Philip.";
err = MXS_INFO("%s", logstr);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
#endif
logstr = "Ph%dlip.";
err = MXS_INFO(logstr, 1);
@ -362,7 +340,7 @@ int main(int argc, char* argv[])
* Test enable/disable log.
*/
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
#endif
succp = mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
ss_dassert(succp);
@ -371,7 +349,7 @@ int main(int argc, char* argv[])
err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0);
skygw_log_disable(LOGFILE_TRACE);
skygw_log_disable(LOG_INFO);
logstr = ("1.\tWrite once to ERROR and twice to MESSAGE log.");
err = MXS_NOTICE("%s", logstr);
@ -381,7 +359,7 @@ int main(int argc, char* argv[])
err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0);
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
logstr = ("2.\tWrite to once to ERROR, twice to MESSAGE and "
"three times to TRACE log.");
@ -392,7 +370,7 @@ int main(int argc, char* argv[])
err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0);
skygw_log_disable(LOGFILE_ERROR);
skygw_log_disable(LOG_ERR);
logstr = ("3.\tWrite to once to MESSAGE and twice to TRACE log.");
err = MXS_NOTICE("%s", logstr);
@ -402,8 +380,8 @@ int main(int argc, char* argv[])
err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0);
skygw_log_disable(LOGFILE_MESSAGE);
skygw_log_disable(LOGFILE_TRACE);
skygw_log_disable(LOG_NOTICE);
skygw_log_disable(LOG_INFO);
logstr = ("4.\tWrite to none.");
err = MXS_NOTICE("%s", logstr);
@ -413,8 +391,8 @@ int main(int argc, char* argv[])
err = MXS_ERROR("%s", logstr);
ss_dassert(err == 0);
skygw_log_enable(LOGFILE_ERROR);
skygw_log_enable(LOGFILE_MESSAGE);
skygw_log_enable(LOG_ERR);
skygw_log_enable(LOG_NOTICE);
logstr = ("4.\tWrite once to ERROR and twice to MESSAGE log.");
err = MXS_NOTICE("%s", logstr);
@ -432,7 +410,7 @@ int main(int argc, char* argv[])
succp = mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
ss_dassert(succp);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
#endif
logstr = ("\tTEST 4 - test spreading logs down to other logs.");
err = MXS_ERROR("%s", logstr);
@ -446,12 +424,12 @@ int main(int argc, char* argv[])
err = MXS_NOTICE("%s", logstr);
ss_dassert(err == 0);
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
logstr = ("3.\tWrite to TRACE log only.");
err = MXS_INFO("%s", logstr);
ss_dassert(err == 0);
skygw_log_disable(LOGFILE_MESSAGE);
skygw_log_disable(LOG_NOTICE);
logstr = ("4.\tWrite to ERROR and thus also to TRACE log. "
"MESSAGE is disabled.");
@ -468,7 +446,7 @@ int main(int argc, char* argv[])
succp = mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
ss_dassert(succp);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
#endif
logstr = ("6.\tWrite to ERROR and thus also to MESSAGE and TRACE logs.");
err = MXS_ERROR("%s", logstr);
@ -479,11 +457,11 @@ int main(int argc, char* argv[])
ss_dassert(err == 0);
logstr = ("8.\tWrite to TRACE log only.");
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
err = MXS_INFO("%s", logstr);
ss_dassert(err == 0);
skygw_log_disable(LOGFILE_MESSAGE);
skygw_log_disable(LOG_NOTICE);
logstr = ("9.\tWrite to ERROR and thus also to TRACE log. "
"MESSAGE is disabled");
@ -495,7 +473,7 @@ int main(int argc, char* argv[])
err = MXS_NOTICE("%s", logstr);
ss_dassert(err == 0);
skygw_log_enable(LOGFILE_MESSAGE);
skygw_log_enable(LOG_NOTICE);
err = MXS_ERROR("11.\tWrite to all logs some formattings : "
"%d %s %d",
@ -572,7 +550,7 @@ static void* thr_run(void* data)
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);
skygw_log_enable(LOG_INFO);
#endif
err = MXS_INFO("%s", logstr);
if (err != 0)
@ -609,7 +587,7 @@ static void* thr_run(void* data)
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
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);
skygw_log_enable(LOG_INFO);
#endif
err = MXS_INFO("%s", logstr);
if (err != 0)
@ -640,12 +618,12 @@ static void* thr_run(void* data)
mxs_log_finish();
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
skygw_log_enable(LOG_INFO);
#endif
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);
skygw_log_enable(LOG_INFO);
#endif
err = MXS_INFO("%s", logstr);
if (err != 0)