Added log manager initialization flag that prints all logs to stdout.
This commit is contained in:
@ -54,7 +54,7 @@ static simple_mutex_t msg_mutex;
|
||||
static int highprec = 0;
|
||||
static int do_syslog = 1;
|
||||
static int do_maxscalelog = 1;
|
||||
|
||||
static int use_stdout = 0;
|
||||
/**
|
||||
* Variable holding the enabled logfiles information.
|
||||
* Used from log users to check enabled logs prior calling
|
||||
@ -1331,12 +1331,14 @@ static bool logfile_set_enabled(
|
||||
}
|
||||
lf = &lm->lm_logfile[id];
|
||||
CHK_LOGFILE(lf);
|
||||
|
||||
if (val) {
|
||||
logstr = strdup("---\tLogging to file is enabled\t--");
|
||||
} else {
|
||||
logstr = strdup("---\tLogging to file is disabled\t--");
|
||||
}
|
||||
if(use_stdout == 0)
|
||||
{
|
||||
if (val) {
|
||||
logstr = strdup("---\tLogging to file is enabled\t--");
|
||||
} else {
|
||||
logstr = strdup("---\tLogging to file is disabled\t--");
|
||||
}
|
||||
|
||||
oldval = lf->lf_enabled;
|
||||
lf->lf_enabled = val;
|
||||
err = logmanager_write_log(id,
|
||||
@ -1348,7 +1350,7 @@ static bool logfile_set_enabled(
|
||||
logstr,
|
||||
notused);
|
||||
free(logstr);
|
||||
|
||||
}
|
||||
if (err != 0) {
|
||||
lf->lf_enabled = oldval;
|
||||
fprintf(stderr,
|
||||
@ -1445,7 +1447,7 @@ int skygw_log_write(
|
||||
* Find out the length of log string (to be formatted str).
|
||||
*/
|
||||
va_start(valist, str);
|
||||
len = vsnprintf(NULL, 0, str, valist);
|
||||
len = vsnprintf(NULL, 0, str, valist);
|
||||
va_end(valist);
|
||||
/**
|
||||
* Add one for line feed.
|
||||
@ -1695,9 +1697,12 @@ static bool fnames_conf_init(
|
||||
fn->fn_chk_tail = CHK_NUM_FNAMES;
|
||||
#endif
|
||||
optind = 1; /**<! reset getopt index */
|
||||
while ((opt = getopt(argc, argv, "+a:b:c:d:e:f:g:h:i:j:l:m:s:")) != -1)
|
||||
while ((opt = getopt(argc, argv, "+a:b:c:d:e:f:g:h:i:j:l:m:s:o")) != -1)
|
||||
{
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
use_stdout = 1;
|
||||
break;
|
||||
case 'a':
|
||||
fn->fn_debug_prefix = strndup(optarg, MAX_PREFIXLEN);
|
||||
break;
|
||||
@ -2153,8 +2158,14 @@ static bool logfile_open_file(
|
||||
bool succp;
|
||||
char* start_msg_str;
|
||||
int err;
|
||||
|
||||
if (lf->lf_store_shmem)
|
||||
|
||||
if(use_stdout)
|
||||
{
|
||||
fw->fwr_file[lf->lf_id] = skygw_file_init_stdout (
|
||||
lf->lf_full_file_name,
|
||||
lf->lf_full_link_name);
|
||||
}
|
||||
else if (lf->lf_store_shmem)
|
||||
{
|
||||
/** Create symlink pointing to log file */
|
||||
fw->fwr_file[lf->lf_id] = skygw_file_init(
|
||||
@ -2177,32 +2188,35 @@ static bool logfile_open_file(
|
||||
succp = false;
|
||||
goto return_succp;
|
||||
}
|
||||
|
||||
if (lf->lf_enabled)
|
||||
{
|
||||
|
||||
if(use_stdout == 0)
|
||||
{
|
||||
if (lf->lf_enabled)
|
||||
{
|
||||
start_msg_str = strdup("---\tLogging is enabled.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
start_msg_str = strdup("---\tLogging is disabled.\n");
|
||||
}
|
||||
err = skygw_file_write(fw->fwr_file[lf->lf_id],
|
||||
(void *)start_msg_str,
|
||||
strlen(start_msg_str),
|
||||
true);
|
||||
|
||||
if (err != 0)
|
||||
{
|
||||
}
|
||||
err = skygw_file_write(fw->fwr_file[lf->lf_id],
|
||||
(void *)start_msg_str,
|
||||
strlen(start_msg_str),
|
||||
true);
|
||||
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Error : writing to file %s failed due to %d, %s. "
|
||||
"Error : writing to file %s failed due to %d, %s. "
|
||||
"Exiting MaxScale.\n",
|
||||
lf->lf_full_file_name,
|
||||
err,
|
||||
strerror(err));
|
||||
lf->lf_full_file_name,
|
||||
err,
|
||||
strerror(err));
|
||||
succp = false;
|
||||
goto return_succp;
|
||||
}
|
||||
free(start_msg_str);
|
||||
}
|
||||
free(start_msg_str);
|
||||
}
|
||||
succp = true;
|
||||
|
||||
return_succp:
|
||||
|
Reference in New Issue
Block a user