Logging target must be explicitly defined.

Whether the log-file should be written to the filesystem or to
shared memory must now be explicitly defined when calling
skygw_logmanager_init() (instead of passing that via the argc/argv
construct).

Also, the meaning of '-l' when invoking maxscale has been changed.

Earlier -l [file|shm] specified whether the trace and debug logs
should be written to shared memory (while the error and message
logs always were written to the filesystem) and the _default_
was to write them to shared memory.

Now, with only one file, '-l' has still the same meaning, but it
decides whether the one and only logfile should be written to shared
memory, or the filesystem and the _default_ is to write it to the
filesystem.
This commit is contained in:
Johan Wikman
2015-11-09 15:53:22 +02:00
parent 90a8646ac2
commit 55dbaa49c0
11 changed files with 58 additions and 86 deletions

View File

@ -122,7 +122,7 @@ int main(int argc, char* argv[])
fprintf(stderr, "Couldn't register exit function.\n");
}
succp = skygw_logmanager_init("/tmp", log_argc, log_argv);
succp = skygw_logmanager_init("/tmp", LOG_TARGET_FS, log_argc, log_argv);
if (!succp)
{
@ -141,7 +141,7 @@ int main(int argc, char* argv[])
tm.tm_min,
tm.tm_sec);
skygw_logmanager_init("/tmp", log_argc, log_argv);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, log_argc, log_argv);
logstr = ("First write with flush.");
err = skygw_log_write_flush(LOGFILE_ERROR, logstr);
@ -189,7 +189,7 @@ int main(int argc, char* argv[])
logstr = "Ph%dlip.";
err = skygw_log_write(LOGFILE_TRACE, logstr, 1);
skygw_logmanager_init("/tmp", log_argc, log_argv);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, log_argc, log_argv);
logstr = ("A terrible error has occurred!");
err = skygw_log_write_flush(LOGFILE_ERROR, logstr);
@ -335,7 +335,7 @@ int main(int argc, char* argv[])
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
#endif
succp = skygw_logmanager_init("/tmp", log_argc, log_argv);
succp = skygw_logmanager_init("/tmp", LOG_TARGET_FS, log_argc, log_argv);
ss_dassert(succp);
logstr = ("\tTEST 3 - test enabling and disabling logs.");
@ -400,7 +400,7 @@ int main(int argc, char* argv[])
#endif /* TEST 3 */
#if defined(TEST4)
succp = skygw_logmanager_init("/tmp", log_argc, log_argv);
succp = skygw_logmanager_init("/tmp", LOG_TARGET_FS, log_argc, log_argv);
ss_dassert(succp);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
@ -436,7 +436,7 @@ int main(int argc, char* argv[])
skygw_logmanager_done();
succp = skygw_logmanager_init("/tmp", log_argc, log_argv);
succp = skygw_logmanager_init("/tmp", LOG_TARGET_FS, log_argc, log_argv);
ss_dassert(succp);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
@ -509,7 +509,7 @@ static void* thr_run(void* data)
char* logstr;
int err;
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
skygw_log_flush(LOGFILE_MESSAGE);
logstr = ("Hi, how are you?");
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
@ -533,7 +533,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
logstr = ("Testing. One, two, three\n");
err = skygw_log_write(LOGFILE_ERROR, logstr);
if (err != 0)
@ -541,8 +541,8 @@ static void* thr_run(void* data)
TEST_ERROR("Error, log write failed.");
}
ss_dassert(err == 0);
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
skygw_log_flush(LOGFILE_ERROR);
logstr = ("For automatic and register variables, it is done each time the function or block is entered.");
@ -556,7 +556,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
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) "
"immediately; the two forms are equivalent. Applying the operatos & to both parts "
@ -568,11 +568,11 @@ static void* thr_run(void* data)
TEST_ERROR("Error, log write failed.");
}
ss_dassert(err == 0);
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_done();
skygw_log_flush(LOGFILE_ERROR);
skygw_logmanager_done();
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
logstr = ("..and you?");
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
if (err != 0)
@ -581,7 +581,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
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);
@ -592,7 +592,7 @@ static void* thr_run(void* data)
TEST_ERROR("Error, log write failed.");
}
ss_dassert(err == 0);
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
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) "
"immediately; the two forms are equivalent. Applying the operatos & to both parts "
@ -604,7 +604,7 @@ static void* thr_run(void* data)
TEST_ERROR("Error, log write failed.");
}
ss_dassert(err == 0);
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
logstr = ("..... and you too?");
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
if (err != 0)
@ -613,7 +613,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
#endif
@ -629,7 +629,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
logstr = ("Testing. One, two, three, four\n");
err = skygw_log_write(LOGFILE_ERROR, logstr);
if (err != 0)
@ -638,7 +638,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
logstr = ("Testing. One, two, three, .. where was I?\n");
err = skygw_log_write(LOGFILE_ERROR, logstr);
if (err != 0)
@ -647,7 +647,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init("/tmp", 0, NULL);
skygw_logmanager_init("/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_done();
simple_mutex_lock(td->mtx, true);
*td->nactive -= 1;