The enabling/disabling of log written to error.log

A change on the path of removing all logs but error.log.
This commit is contained in:
Johan Wikman
2015-11-02 14:21:44 +02:00
parent 0d8faa6840
commit 142c22c2a8

View File

@ -1284,68 +1284,63 @@ return_err:
static bool logfile_set_enabled(logfile_id_t id, bool val) static bool logfile_set_enabled(logfile_id_t id, bool val)
{ {
char* logstr; bool rval = false;
bool oldval;
bool succp = false;
int err = 0;
logfile_t* lf;
CHK_LOGMANAGER(lm); CHK_LOGMANAGER(lm);
if (id < LOGFILE_FIRST || id > LOGFILE_LAST) if (logmanager_is_valid_id(id))
{ {
const char* errstr = "Invalid logfile id argument.";
/**
* invalid id, since we don't have logfile yet.
*/
err = logmanager_write_log(LOGFILE_ERROR,
LOG_FLUSH_YES,
0,
strlen(errstr) + 1,
errstr);
if (err != 0)
{
fprintf(stderr,
"* Writing to logfile %s failed.\n",
STRLOGID(LOGFILE_ERROR));
}
ss_dassert(false);
goto return_succp;
}
lf = &lm->lm_logfile[id];
CHK_LOGFILE(lf);
if (use_stdout == 0) if (use_stdout == 0)
{ {
logfile_t *lf = logmanager_get_logfile(lm, id);
lf->lf_enabled = val;
const char *name;
switch (id)
{
default:
case LOGFILE_ERROR:
name = "LOGFILE_ERROR";
break;
case LOGFILE_MESSAGE:
name = "LOGFILE_MESSAGE";
break;
case LOGFILE_TRACE:
name = "LOGFILE_TRACE";
break;
case LOGFILE_DEBUG:
name = "LOGFILE_DEBUG";
break;
}
const char FORMAT[] = "The logging of %s messages is %s.";
const char *action;
if (val) if (val)
{ {
logstr = strdup("---\tLogging to file is enabled\t--"); action = "enabled";
} }
else else
{ {
logstr = strdup("---\tLogging to file is disabled\t--"); action = "disabled";
} }
oldval = lf->lf_enabled; MXS_NOTICE(FORMAT, name, action);
lf->lf_enabled = val;
err = logmanager_write_log(id,
LOG_FLUSH_YES,
0,
strlen(logstr) + 1,
logstr);
free(logstr);
} }
if (err != 0)
rval = true;
}
else
{ {
lf->lf_enabled = oldval; MXS_ERROR("Invalid logfile id %d.", id);
fprintf(stderr, ss_dassert(!true);
"logfile_set_enabled failed. Writing notification to logfile %s "
"failed.\n ",
STRLOGID(id));
goto return_succp;
} }
succp = true;
return_succp: return rval;
return succp;
} }
void skygw_log_set_augmentation(int bits) void skygw_log_set_augmentation(int bits)