version 1.1.1.2, 2016/11/01 09:56:12
|
version 1.1.1.4, 2021/03/17 00:39:23
|
Line 176 LogClose(void)
|
Line 176 LogClose(void)
|
*/ |
*/ |
|
|
int |
int |
LogCommand(Context ctx, int ac, char *av[], void *arg) | LogCommand(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
u_int k; |
u_int k; |
int bits, add; |
int bits, add; |
|
const char *s; |
|
|
|
(void)arg; |
if (ac == 0) { |
if (ac == 0) { |
#define LG_FMT " %-12s %-10s %s\r\n" |
#define LG_FMT " %-12s %-10s %s\r\n" |
|
|
Line 195 LogCommand(Context ctx, int ac, char *av[], void *arg)
|
Line 197 LogCommand(Context ctx, int ac, char *av[], void *arg)
|
} |
} |
|
|
while (ac--) { |
while (ac--) { |
switch (**av) { | s = *av; |
| switch (*s) { |
case '+': |
case '+': |
(*av)++; | s++; |
default: |
default: |
add = TRUE; |
add = TRUE; |
break; |
break; |
case '-': |
case '-': |
add = FALSE; |
add = FALSE; |
(*av)++; | s++; |
break; |
break; |
} |
} |
for (k = 0; |
for (k = 0; |
k < NUM_LOG_LEVELS && strcasecmp(*av, LogOptionList[k].name); | k < NUM_LOG_LEVELS && strcasecmp(s, LogOptionList[k].name); |
k++); |
k++); |
if (k < NUM_LOG_LEVELS) |
if (k < NUM_LOG_LEVELS) |
bits = LogOptionList[k].mask; |
bits = LogOptionList[k].mask; |
else { |
else { |
if (!strcasecmp(*av, "all")) { | if (!strcasecmp(s, "all")) { |
for (bits = k = 0; k < NUM_LOG_LEVELS; k++) |
for (bits = k = 0; k < NUM_LOG_LEVELS; k++) |
bits |= LogOptionList[k].mask; |
bits |= LogOptionList[k].mask; |
} else { |
} else { |
Printf("\"%s\" is unknown. Enter \"log\" for list.\r\n", *av); | Printf("\"%s\" is unknown. Enter \"log\" for list.\r\n", s); |
bits = 0; |
bits = 0; |
} |
} |
} |
} |
Line 246 LogPrintf(const char *fmt, ...)
|
Line 249 LogPrintf(const char *fmt, ...)
|
} |
} |
|
|
void |
void |
vLogPrintf(const char *fmt, va_list args) | vLogPrintf(const char *fmt, va_list args) NO_THREAD_SAFETY_ANALYSIS |
{ |
{ |
if (!SLIST_EMPTY(&gConsole.sessions)) { |
if (!SLIST_EMPTY(&gConsole.sessions)) { |
char buf[1000]; |
char buf[1000]; |
Line 256 vLogPrintf(const char *fmt, va_list args)
|
Line 259 vLogPrintf(const char *fmt, va_list args)
|
#ifdef SYSLOG_FACILITY |
#ifdef SYSLOG_FACILITY |
syslog(LOG_INFO, "%s", buf); |
syslog(LOG_INFO, "%s", buf); |
#endif |
#endif |
|
pthread_cleanup_push(ConsoleCancelCleanup, gConsole.lock); |
RWLOCK_RDLOCK(gConsole.lock); |
RWLOCK_RDLOCK(gConsole.lock); |
SLIST_FOREACH(s, &gConsole.sessions, next) { |
SLIST_FOREACH(s, &gConsole.sessions, next) { |
if (Enabled(&s->options, CONSOLE_LOGGING)) |
if (Enabled(&s->options, CONSOLE_LOGGING)) |
s->write(s, "%s\r\n", buf); |
s->write(s, "%s\r\n", buf); |
} |
} |
RWLOCK_UNLOCK(gConsole.lock); | pthread_cleanup_pop(1); |
#ifdef SYSLOG_FACILITY |
#ifdef SYSLOG_FACILITY |
} else { |
} else { |
vsyslog(LOG_INFO, fmt, args); |
vsyslog(LOG_INFO, fmt, args); |
Line 296 LogPrintf2(const char *fmt, ...)
|
Line 300 LogPrintf2(const char *fmt, ...)
|
void |
void |
LogDumpBp2(Mbuf bp, const char *fmt, ...) |
LogDumpBp2(Mbuf bp, const char *fmt, ...) |
{ |
{ |
int k, total; | int k; |
| unsigned total; |
u_char bytes[DUMP_BYTES_PER_LINE]; |
u_char bytes[DUMP_BYTES_PER_LINE]; |
char line[128]; |
char line[128]; |
int linelen; |
int linelen; |
Line 316 LogDumpBp2(Mbuf bp, const char *fmt, ...)
|
Line 321 LogDumpBp2(Mbuf bp, const char *fmt, ...)
|
|
|
total = 0; |
total = 0; |
if (bp) { |
if (bp) { |
int start, stop, last = 0; | int start, last = 0; |
| unsigned stop; |
|
|
stop = ROUNDUP(total + MBLEN(bp), DUMP_BYTES_PER_LINE); |
stop = ROUNDUP(total + MBLEN(bp), DUMP_BYTES_PER_LINE); |
for (start = total; total < stop; ) { |
for (start = total; total < stop; ) { |