The list of accepted tokens is documented in the manual page.
if (msg && msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = '\0';
switch (slm->priority) {
- case LOG_EMERG: log_warnx("snmp", "%s", msg?msg:slm->msg); break;
- case LOG_ALERT: log_warnx("snmp", "%s", msg?msg:slm->msg); break;
- case LOG_CRIT: log_warnx("snmp", "%s", msg?msg:slm->msg); break;
- case LOG_ERR: log_warnx("snmp", "%s", msg?msg:slm->msg); break;
- case LOG_WARNING: log_warnx("snmp", "%s", msg?msg:slm->msg); break;
- case LOG_NOTICE: log_info ("snmp", "%s", msg?msg:slm->msg); break;
- case LOG_INFO: log_info ("snmp", "%s", msg?msg:slm->msg); break;
- case LOG_DEBUG: log_debug("snmp", "%s", msg?msg:slm->msg); break;
+ case LOG_EMERG: log_warnx("libsnmp", "%s", msg?msg:slm->msg); break;
+ case LOG_ALERT: log_warnx("libsnmp", "%s", msg?msg:slm->msg); break;
+ case LOG_CRIT: log_warnx("libsnmp", "%s", msg?msg:slm->msg); break;
+ case LOG_ERR: log_warnx("libsnmp", "%s", msg?msg:slm->msg); break;
+ case LOG_WARNING: log_warnx("libsnmp", "%s", msg?msg:slm->msg); break;
+ case LOG_NOTICE: log_info ("libsnmp", "%s", msg?msg:slm->msg); break;
+ case LOG_INFO: log_info ("libsnmp", "%s", msg?msg:slm->msg); break;
+ case LOG_DEBUG: log_debug("libsnmp", "%s", msg?msg:slm->msg); break;
}
free(msg);
return SNMP_ERR_NOERROR;
return 0;
}
- log_debug("interface", "%s passes the minimal checks",
+ log_debug("interfaces", "%s passes the minimal checks",
ifa->ifa_name);
return 1;
}
if ((master = iface_is_enslaved(cfg, ifa->ifa_name)) == -1)
continue;
- log_debug("interface", "%s is an acceptable bonded device (master=%d)",
+ log_debug("interfaces", "%s is an acceptable bonded device (master=%d)",
ifa->ifa_name, master);
if ((hardware = lldpd_get_hardware(cfg,
ifa->ifa_name,
.Sh SYNOPSIS
.Nm
.Op Fl dxcseiklrv
+.Op Fl D Ar debug
.Op Fl S Ar description
.Op Fl P Ar platform
.Op Fl X Ar socket
.Nm
will run in the foreground and log to
.Em stderr .
-This option can be specified many times to increase verbosity.
+This option can be specified many times to increase verbosity. When
+specified three times, debug logs will be enabled. They can be
+filtered with
+.Fl D
+flag.
+.It Fl D Ar debug
+This option allows the user to filter out debugging information by
+specifying allowed tokens. This option can be repeated several times
+to allow several tokens. This option must be combined with the
+.Fl d
+flag to have some effect. Only debugging logs can be filtered. Here is
+a list of allowed tokens with their description:
+.Bl -tag -width "XXXXXXXXXX" -offset "XXXX" -compact
+.It Sy main
+Main daemon.
+.It Sy interfaces
+Discovery of local interfaces.
+.It Sy lldp
+LLDP PDU encoding/decoding.
+.It Sy edp
+EDP PDU encoding/decoding.
+.It Sy cdp
+CDP/FDP PDU encoding/decoding.
+.It Sy sonmp
+SONMP PDU encoding/decoding.
+.It Sy event
+Events management.
+.It Sy libevent
+Events management but for logs generated by libevent.
+.It Sy privsep
+Privilege separation.
+.It Sy localchassis
+Retrieval of information related to the local chassis.
+.It Sy rpc
+Client communication.
+.It Sy control
+Management of the Unix control socket.
+.It Sy snmp
+SNMP subagent.
+.It Sy libsnmp
+SNMP subagent but for logs generated by NetSNMP.
+.It Sy decode
+Generic PDU decoding.
+.It Sy marshal
+Low-level serialization mechanisms.
+.It Sy alloc
+Low-level allocation mechanisms.
+.It Sy send
+Sending PDU to some interface.
+.It Sy receive
+Receiving PDU from some interface.
+.It Sy loop
+Main loop.
+.It Sy smartfilter
+Smart filtering of different protocols on the same port.
+.El
.It Fl k
Disable advertising of kernel release, version and machine. Kernel name
(ie: Linux) will still be shared, and Inventory software version will be set
};
lldpd_ifhandlers *ifh;
- log_debug("localports", "update information for local ports");
+ log_debug("localchassis", "update information for local ports");
/* h_flags is set to 0 for each port. If the port is updated, h_flags
* will be set to a non-zero value. This will allow us to clean up any
hardware->h_flags = 0;
if (getifaddrs(&ifap) != 0)
- fatal("localports", "failed to get interface list");
+ fatal("localchassis", "failed to get interface list");
/* We will run the list of interfaces through a list of interface
* handlers. Each handler will create or update some hardware port (and
lldpd_exit(struct lldpd *cfg)
{
struct lldpd_hardware *hardware, *hardware_next;
- log_debug("exit", "exit lldpd");
+ log_debug("main", "exit lldpd");
close(cfg->g_ctl);
priv_ctl_cleanup();
- log_debug("exit", "cleanup hardware information");
+ log_debug("main", "cleanup hardware information");
for (hardware = TAILQ_FIRST(&cfg->g_hardware); hardware != NULL;
hardware = hardware_next) {
hardware_next = TAILQ_NEXT(hardware, h_entries);
- log_debug("exit", "cleanup interface %s", hardware->h_ifname);
+ log_debug("main", "cleanup interface %s", hardware->h_ifname);
lldpd_remote_cleanup(hardware, NULL);
lldpd_hardware_cleanup(cfg, hardware);
}
char *cidp = NULL;
char *interfaces = NULL;
char *popt, opts[] =
- "H:vhkrdxX:m:4:6:I:C:p:M:P:S:i@ ";
+ "H:vhkrdD:xX:m:4:6:I:C:p:M:P:S:i@ ";
int i, found, advertise_version = 1;
#ifdef ENABLE_LLDPMED
int lldpmed = 0, noinventory = 0;
case 'd':
debug++;
break;
+ case 'D':
+ log_accept(optarg);
+ break;
case 'r':
receiveonly = 1;
break;
va_end(ap);
return atom;
}
- log_warnx("atom", "unknown atom type: %d", type);
+ log_warnx("rpc", "unknown atom type: %d", type);
SET_ERROR(conn, LLDPCTL_ERR_FATAL);
return NULL;
}
static void vlog(int, const char *, const char *, va_list);
static void logit(int, const char *, const char *, ...);
+#define MAX_DBG_TOKENS 40
+static const char const *tokens[MAX_DBG_TOKENS + 1] = {NULL};
+
void
log_init(int n_debug, const char *progname)
{
logh = cb;
}
+void
+log_accept(const char *token)
+{
+ int i;
+ for (i = 0; i < MAX_DBG_TOKENS; i++) {
+ if (tokens[i] == NULL) {
+ tokens[i+1] = NULL;
+ tokens[i] = token;
+ return;
+ }
+ }
+}
static void
logit(int pri, const char *token, const char *fmt, ...)
}
}
+static int
+log_debug_accept_token(const char *token)
+{
+ int i;
+ if (tokens[0] == NULL) return 1;
+ for (i = 0;
+ (i < MAX_DBG_TOKENS) && (tokens[i] != NULL);
+ i++) {
+ if (!strcmp(tokens[i], token))
+ return 1;
+ }
+ return 0;
+}
+
void
log_debug(const char *token, const char *emsg, ...)
{
va_list ap;
- if (debug > 2 || logh) {
+ if ((debug > 2 && log_debug_accept_token(token)) || logh) {
va_start(ap, emsg);
vlog(LOG_DEBUG, token, emsg, ap);
va_end(ap);
void fatalx(const char *);
void log_register(void (*cb)(int, const char*));
+void log_accept(const char *);
#endif