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;
|
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.
|
* @node Register as a logging client to logmanager.
|
||||||
*
|
*
|
||||||
@ -2717,7 +2676,28 @@ int mxs_log_flush()
|
|||||||
*/
|
*/
|
||||||
int mxs_log_rotate()
|
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)
|
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);
|
void skygw_log_done(void);
|
||||||
int skygw_log_flush(logfile_id_t id);
|
int skygw_log_flush(logfile_id_t id);
|
||||||
void skygw_log_sync_all(void);
|
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_enable(logfile_id_t id);
|
||||||
int skygw_log_disable(logfile_id_t id);
|
int skygw_log_disable(logfile_id_t id);
|
||||||
void skygw_log_sync_all(void);
|
void skygw_log_sync_all(void);
|
||||||
|
@ -307,10 +307,7 @@ static void sigusr1_handler (int i)
|
|||||||
LOGIF(LM, (skygw_log_write(
|
LOGIF(LM, (skygw_log_write(
|
||||||
LOGFILE_MESSAGE,
|
LOGFILE_MESSAGE,
|
||||||
"Log file flush following reception of SIGUSR1\n")));
|
"Log file flush following reception of SIGUSR1\n")));
|
||||||
skygw_log_rotate(LOGFILE_ERROR);
|
mxs_log_rotate();
|
||||||
skygw_log_rotate(LOGFILE_MESSAGE);
|
|
||||||
skygw_log_rotate(LOGFILE_TRACE);
|
|
||||||
skygw_log_rotate(LOGFILE_DEBUG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sigterm_handler (int i) {
|
static void sigterm_handler (int i) {
|
||||||
|
@ -613,29 +613,48 @@ struct subcommand removeoptions[] = {
|
|||||||
static void
|
static void
|
||||||
flushlog(DCB *pdcb, char *logname)
|
flushlog(DCB *pdcb, char *logname)
|
||||||
{
|
{
|
||||||
if (logname == NULL)
|
bool unrecognized = false;
|
||||||
|
bool deprecated = false;
|
||||||
|
|
||||||
|
if (!strcasecmp(logname, "error"))
|
||||||
{
|
{
|
||||||
}
|
deprecated = true;
|
||||||
else if (!strcasecmp(logname, "error"))
|
|
||||||
{
|
|
||||||
skygw_log_rotate(LOGFILE_ERROR);
|
|
||||||
}
|
}
|
||||||
else if (!strcasecmp(logname, "message"))
|
else if (!strcasecmp(logname, "message"))
|
||||||
{
|
{
|
||||||
skygw_log_rotate(LOGFILE_MESSAGE);
|
deprecated = true;
|
||||||
}
|
}
|
||||||
else if (!strcasecmp(logname, "trace"))
|
else if (!strcasecmp(logname, "trace"))
|
||||||
{
|
{
|
||||||
skygw_log_rotate(LOGFILE_TRACE);
|
deprecated = true;
|
||||||
}
|
}
|
||||||
else if (!strcasecmp(logname, "debug"))
|
else if (!strcasecmp(logname, "debug"))
|
||||||
{
|
{
|
||||||
skygw_log_rotate(LOGFILE_DEBUG);
|
deprecated = true;
|
||||||
|
}
|
||||||
|
else if (!strcasecmp(logname, "maxscale"))
|
||||||
|
{
|
||||||
|
; // nop
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dcb_printf(pdcb, "Unexpected logfile name, expected "
|
unrecognized = true;
|
||||||
"error, message, trace or debug.\n");
|
}
|
||||||
|
|
||||||
|
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
|
static void
|
||||||
flushlogs(DCB *pdcb)
|
flushlogs(DCB *pdcb)
|
||||||
{
|
{
|
||||||
skygw_log_rotate(LOGFILE_ERROR);
|
mxs_log_rotate();
|
||||||
skygw_log_rotate(LOGFILE_MESSAGE);
|
|
||||||
skygw_log_rotate(LOGFILE_TRACE);
|
|
||||||
skygw_log_rotate(LOGFILE_DEBUG);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -670,8 +686,8 @@ struct subcommand flushoptions[] = {
|
|||||||
"logs",
|
"logs",
|
||||||
0,
|
0,
|
||||||
flushlogs,
|
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 those 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",
|
||||||
{0, 0, 0}
|
{0, 0, 0}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -303,10 +303,7 @@ char errmsg[120];
|
|||||||
*/
|
*/
|
||||||
void exec_flush_logs(DCB *dcb, MAXINFO_TREE *tree)
|
void exec_flush_logs(DCB *dcb, MAXINFO_TREE *tree)
|
||||||
{
|
{
|
||||||
skygw_log_rotate(LE);
|
mxs_log_rotate();
|
||||||
skygw_log_rotate(LM);
|
|
||||||
skygw_log_rotate(LT);
|
|
||||||
skygw_log_rotate(LD);
|
|
||||||
maxinfo_send_ok(dcb);
|
maxinfo_send_ok(dcb);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1252,4 +1249,4 @@ void maxinfo_send_ok(DCB *dcb)
|
|||||||
memcpy(buffer->start, ok_packet, sizeof(ok_packet));
|
memcpy(buffer->start, ok_packet, sizeof(ok_packet));
|
||||||
dcb->func.write(dcb, buffer);
|
dcb->func.write(dcb, buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user