Log: skygw_log_rotate replaced with mxs_log_rotate.
With only one log-file no arguments are needed. The maxadmin command 'flush log' still accepts all the previous arguments, but warns about them being deprecated.
This commit is contained in:
@ -1349,47 +1349,6 @@ int skygw_log_flush(logfile_id_t id)
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace current logfile with new file with increased sequence number on
|
||||
* its name.
|
||||
*/
|
||||
int skygw_log_rotate(logfile_id_t id)
|
||||
{
|
||||
int err = -1;
|
||||
|
||||
if (id == LOGFILE_ERROR)
|
||||
{
|
||||
if (logmanager_register(false))
|
||||
{
|
||||
CHK_LOGMANAGER(lm);
|
||||
|
||||
logfile_t *lf = logmanager_get_logfile(lm);
|
||||
CHK_LOGFILE(lf);
|
||||
|
||||
MXS_NOTICE("Log rotation is called for %s.", lf->lf_full_file_name);
|
||||
|
||||
logfile_rotate(lf);
|
||||
err = 0;
|
||||
|
||||
logmanager_unregister();
|
||||
}
|
||||
else
|
||||
{
|
||||
ss_dfprintf(stderr, "Can't register to logmanager, rotating failed.\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We'll pretend everything went ok.
|
||||
err = 0;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @node Register as a logging client to logmanager.
|
||||
*
|
||||
@ -2717,7 +2676,28 @@ int mxs_log_flush()
|
||||
*/
|
||||
int mxs_log_rotate()
|
||||
{
|
||||
return skygw_log_rotate(LOGFILE_ERROR);
|
||||
int err = -1;
|
||||
|
||||
if (logmanager_register(false))
|
||||
{
|
||||
CHK_LOGMANAGER(lm);
|
||||
|
||||
logfile_t *lf = logmanager_get_logfile(lm);
|
||||
CHK_LOGFILE(lf);
|
||||
|
||||
MXS_NOTICE("Log rotation is called for %s.", lf->lf_full_file_name);
|
||||
|
||||
logfile_rotate(lf);
|
||||
err = 0;
|
||||
|
||||
logmanager_unregister();
|
||||
}
|
||||
else
|
||||
{
|
||||
ss_dfprintf(stderr, "Can't register to logmanager, rotating failed.\n");
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static bool convert_priority_to_file(int priority, logfile_id_t* idp, const char** textp)
|
||||
|
@ -159,7 +159,6 @@ void skygw_logmanager_exit(void);
|
||||
void skygw_log_done(void);
|
||||
int skygw_log_flush(logfile_id_t id);
|
||||
void skygw_log_sync_all(void);
|
||||
int skygw_log_rotate(logfile_id_t id);
|
||||
int skygw_log_enable(logfile_id_t id);
|
||||
int skygw_log_disable(logfile_id_t id);
|
||||
void skygw_log_sync_all(void);
|
||||
|
@ -307,10 +307,7 @@ static void sigusr1_handler (int i)
|
||||
LOGIF(LM, (skygw_log_write(
|
||||
LOGFILE_MESSAGE,
|
||||
"Log file flush following reception of SIGUSR1\n")));
|
||||
skygw_log_rotate(LOGFILE_ERROR);
|
||||
skygw_log_rotate(LOGFILE_MESSAGE);
|
||||
skygw_log_rotate(LOGFILE_TRACE);
|
||||
skygw_log_rotate(LOGFILE_DEBUG);
|
||||
mxs_log_rotate();
|
||||
}
|
||||
|
||||
static void sigterm_handler (int i) {
|
||||
|
@ -613,29 +613,48 @@ struct subcommand removeoptions[] = {
|
||||
static void
|
||||
flushlog(DCB *pdcb, char *logname)
|
||||
{
|
||||
if (logname == NULL)
|
||||
bool unrecognized = false;
|
||||
bool deprecated = false;
|
||||
|
||||
if (!strcasecmp(logname, "error"))
|
||||
{
|
||||
}
|
||||
else if (!strcasecmp(logname, "error"))
|
||||
{
|
||||
skygw_log_rotate(LOGFILE_ERROR);
|
||||
deprecated = true;
|
||||
}
|
||||
else if (!strcasecmp(logname, "message"))
|
||||
{
|
||||
skygw_log_rotate(LOGFILE_MESSAGE);
|
||||
deprecated = true;
|
||||
}
|
||||
else if (!strcasecmp(logname, "trace"))
|
||||
{
|
||||
skygw_log_rotate(LOGFILE_TRACE);
|
||||
deprecated = true;
|
||||
}
|
||||
else if (!strcasecmp(logname, "debug"))
|
||||
{
|
||||
skygw_log_rotate(LOGFILE_DEBUG);
|
||||
deprecated = true;
|
||||
}
|
||||
else if (!strcasecmp(logname, "maxscale"))
|
||||
{
|
||||
; // nop
|
||||
}
|
||||
else
|
||||
{
|
||||
dcb_printf(pdcb, "Unexpected logfile name, expected "
|
||||
"error, message, trace or debug.\n");
|
||||
unrecognized = true;
|
||||
}
|
||||
|
||||
if (unrecognized)
|
||||
{
|
||||
dcb_printf(pdcb, "Unexpected logfile name '%s', expected: 'maxscale'.\n", logname);
|
||||
}
|
||||
else
|
||||
{
|
||||
mxs_log_rotate();
|
||||
|
||||
if (deprecated)
|
||||
{
|
||||
dcb_printf(pdcb,
|
||||
"'%s' is deprecated, currently there is only one log 'maxscale', "
|
||||
"which was rotated.\n", logname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -647,10 +666,7 @@ flushlog(DCB *pdcb, char *logname)
|
||||
static void
|
||||
flushlogs(DCB *pdcb)
|
||||
{
|
||||
skygw_log_rotate(LOGFILE_ERROR);
|
||||
skygw_log_rotate(LOGFILE_MESSAGE);
|
||||
skygw_log_rotate(LOGFILE_TRACE);
|
||||
skygw_log_rotate(LOGFILE_DEBUG);
|
||||
mxs_log_rotate();
|
||||
}
|
||||
|
||||
|
||||
@ -670,8 +686,8 @@ struct subcommand flushoptions[] = {
|
||||
"logs",
|
||||
0,
|
||||
flushlogs,
|
||||
"Flush the content of all log files, close that logs, rename them and open a new log files",
|
||||
"Flush the content of all log files, close that logs, rename them and open a new log files",
|
||||
"Flush the content of all log files, close those logs, rename them and open a new log files",
|
||||
"Flush the content of all log files, close those logs, rename them and open a new log files",
|
||||
{0, 0, 0}
|
||||
},
|
||||
{
|
||||
|
@ -303,10 +303,7 @@ char errmsg[120];
|
||||
*/
|
||||
void exec_flush_logs(DCB *dcb, MAXINFO_TREE *tree)
|
||||
{
|
||||
skygw_log_rotate(LE);
|
||||
skygw_log_rotate(LM);
|
||||
skygw_log_rotate(LT);
|
||||
skygw_log_rotate(LD);
|
||||
mxs_log_rotate();
|
||||
maxinfo_send_ok(dcb);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user