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."; if (use_stdout == 0)
/**
* 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, logfile_t *lf = logmanager_get_logfile(lm, id);
"* Writing to logfile %s failed.\n", lf->lf_enabled = val;
STRLOGID(LOGFILE_ERROR));
} const char *name;
ss_dassert(false);
goto return_succp; switch (id)
} {
lf = &lm->lm_logfile[id]; default:
CHK_LOGFILE(lf); case LOGFILE_ERROR:
if (use_stdout == 0) name = "LOGFILE_ERROR";
{ break;
if (val)
{ case LOGFILE_MESSAGE:
logstr = strdup("---\tLogging to file is enabled\t--"); name = "LOGFILE_MESSAGE";
} break;
else
{ case LOGFILE_TRACE:
logstr = strdup("---\tLogging to file is disabled\t--"); 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)
{
action = "enabled";
}
else
{
action = "disabled";
}
MXS_NOTICE(FORMAT, name, action);
} }
oldval = lf->lf_enabled; rval = true;
lf->lf_enabled = val;
err = logmanager_write_log(id,
LOG_FLUSH_YES,
0,
strlen(logstr) + 1,
logstr);
free(logstr);
} }
if (err != 0) 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)