mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
specify a "script log level" on the commandline to set under which log
level any/all output from eventscripts will be logged as (This used to be ctdb commit cdc79d4f22f1a6aec5c34115969421f93663932a)
This commit is contained in:
parent
4a66281cb6
commit
ce66008e08
@ -1423,4 +1423,6 @@ void ctdb_canonicalize_ip(const ctdb_sock_addr *ip, ctdb_sock_addr *cip);
|
||||
|
||||
int32_t ctdb_control_recd_ping(struct ctdb_context *ctdb);
|
||||
|
||||
extern int script_log_level;
|
||||
|
||||
#endif
|
||||
|
@ -151,6 +151,8 @@ static void ctdb_log_handler(struct event_context *ev, struct fd_event *fde,
|
||||
ctdb->log->buf_used += n;
|
||||
}
|
||||
|
||||
this_log_level = script_log_level;
|
||||
|
||||
while (ctdb->log->buf_used > 0 &&
|
||||
(p = memchr(ctdb->log->buf, '\n', ctdb->log->buf_used)) != NULL) {
|
||||
int n1 = (p - ctdb->log->buf)+1;
|
||||
@ -159,7 +161,9 @@ static void ctdb_log_handler(struct event_context *ev, struct fd_event *fde,
|
||||
if (n2 > 0 && ctdb->log->buf[n2-1] == '\r') {
|
||||
n2--;
|
||||
}
|
||||
do_debug("%*.*s\n", n2, n2, ctdb->log->buf);
|
||||
if (script_log_level <= LogLevel) {
|
||||
do_debug("%*.*s\n", n2, n2, ctdb->log->buf);
|
||||
}
|
||||
memmove(ctdb->log->buf, p+1, sizeof(ctdb->log->buf) - n1);
|
||||
ctdb->log->buf_used -= n1;
|
||||
}
|
||||
@ -167,8 +171,10 @@ static void ctdb_log_handler(struct event_context *ev, struct fd_event *fde,
|
||||
/* the buffer could have completely filled - unfortunately we have
|
||||
no choice but to dump it out straight away */
|
||||
if (ctdb->log->buf_used == sizeof(ctdb->log->buf)) {
|
||||
do_debug("%*.*s\n",
|
||||
(int)ctdb->log->buf_used, (int)ctdb->log->buf_used, ctdb->log->buf);
|
||||
if (script_log_level <= LogLevel) {
|
||||
do_debug("%*.*s\n",
|
||||
(int)ctdb->log->buf_used, (int)ctdb->log->buf_used, ctdb->log->buf);
|
||||
}
|
||||
ctdb->log->buf_used = 0;
|
||||
}
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ static struct {
|
||||
int no_lmaster;
|
||||
int no_recmaster;
|
||||
int lvs;
|
||||
int script_log_level;
|
||||
} options = {
|
||||
.nlist = ETCDIR "/ctdb/nodes",
|
||||
.transport = "tcp",
|
||||
@ -53,8 +54,10 @@ static struct {
|
||||
.logfile = VARDIR "/log/log.ctdb",
|
||||
.db_dir = VARDIR "/ctdb",
|
||||
.db_dir_persistent = VARDIR "/ctdb/persistent",
|
||||
.script_log_level = DEBUG_ERR,
|
||||
};
|
||||
|
||||
int script_log_level;
|
||||
|
||||
/*
|
||||
called by the transport layer when a packet comes in
|
||||
@ -126,6 +129,7 @@ int main(int argc, const char *argv[])
|
||||
{ "no-lmaster", 0, POPT_ARG_NONE, &options.no_lmaster, 0, "disable lmaster role on this node", NULL },
|
||||
{ "no-recmaster", 0, POPT_ARG_NONE, &options.no_recmaster, 0, "disable recmaster role on this node", NULL },
|
||||
{ "lvs", 0, POPT_ARG_NONE, &options.lvs, 0, "lvs is enabled on this node", NULL },
|
||||
{ "script-log-level", 0, POPT_ARG_INT, &options.script_log_level, DEBUG_ERR, "log level of event script output", NULL },
|
||||
POPT_TABLEEND
|
||||
};
|
||||
int opt, ret;
|
||||
@ -167,6 +171,8 @@ int main(int argc, const char *argv[])
|
||||
|
||||
ctdb->start_as_disabled = options.start_as_disabled;
|
||||
|
||||
script_log_level = options.script_log_level;
|
||||
|
||||
ret = ctdb_set_logfile(ctdb, options.logfile, options.use_syslog);
|
||||
if (ret == -1) {
|
||||
printf("ctdb_set_logfile to %s failed - %s\n",
|
||||
|
Loading…
Reference in New Issue
Block a user