diff options
-rw-r--r-- | src/log.h | 3 | ||||
-rw-r--r-- | src/log_colored.c | 5 | ||||
-rw-r--r-- | src/log_colored.h | 1 | ||||
-rw-r--r-- | src/log_file.c | 5 | ||||
-rw-r--r-- | src/main.c | 2 | ||||
-rw-r--r-- | src/options.c | 10 | ||||
-rw-r--r-- | src/protocol_ssh.c | 10 |
7 files changed, 25 insertions, 11 deletions
@@ -40,9 +40,10 @@ } \ } #define C(fmt, ...) log_fmt(CMD, fmt, __VA_ARGS__) +#define P(fmt, ...) log_fmt(PROTOCOL, fmt, __VA_ARGS__) typedef enum log_priority { - DEBUG = 0, NOTICE, WARNING, ERROR, CMD + DEBUG = 0, PROTOCOL, NOTICE, WARNING, ERROR, CMD } log_priority; typedef int (*log_open_cb) (void); diff --git a/src/log_colored.c b/src/log_colored.c index 946f802..e27100f 100644 --- a/src/log_colored.c +++ b/src/log_colored.c @@ -81,6 +81,9 @@ void log_fmt_colored(log_priority prio, const char *fmt, ...) case CMD: LOG(time, "[" BLU "CMD" RESET "] ", my_pid, out); break; + case PROTOCOL: + LOG(time, "[" CYA "PROTO" RESET "] ", my_pid, out); + break; } } @@ -115,6 +118,7 @@ void log_fmtex_colored(log_priority prio, const char *srcfile, LOGEX(time, "[" RED "ERROR" RESET "] ", my_pid, srcfile, line, out); break; case CMD: + case PROTOCOL: break; } } @@ -151,6 +155,7 @@ void log_fmtexerr_colored(log_priority prio, const char *srcfile, LOGEXERR(time, "[" RED "ERROR" RESET "] ", my_pid, srcfile, line, out, saved_errno); break; case CMD: + case PROTOCOL: break; } } diff --git a/src/log_colored.h b/src/log_colored.h index 422cbe7..122dddc 100644 --- a/src/log_colored.h +++ b/src/log_colored.h @@ -9,6 +9,7 @@ #define YEL "\x1B[33;1m" #define RED "\x1B[31;1;5m" #define BLU "\x1B[34;1;1m" +#define CYA "\x1B[36;1;1m" /* LOG_SET_FUNCS comfort */ #define LOG_COLORED_FUNCS log_open_colored, log_close_colored, \ log_fmt_colored, log_fmtex_colored, log_fmtexerr_colored diff --git a/src/log_file.c b/src/log_file.c index c909e8f..63e30e9 100644 --- a/src/log_file.c +++ b/src/log_file.c @@ -89,6 +89,9 @@ void log_fmt_file(log_priority prio, const char *fmt, ...) case CMD: LOG(flog, time, "[CMD] ", my_pid, out); break; + case PROTOCOL: + LOG(flog, time, "[PROTO] ", my_pid, out); + break; } } @@ -123,6 +126,7 @@ void log_fmtex_file(log_priority prio, const char *srcfile, LOGEX(flog, time, "[ERROR] ", my_pid, srcfile, line, out); break; case CMD: + case PROTOCOL: break; } } @@ -163,6 +167,7 @@ void log_fmtexerr_file(log_priority prio, const char *srcfile, saved_errno); break; case CMD: + case PROTOCOL: break; } } @@ -317,6 +317,8 @@ int main(int argc, char *argv[]) value = getopt_str(OPT_LOGLEVEL); if (!strcasecmp(value, "debug")) log_prio = DEBUG; + else if (!strcasecmp(value, "protocol")) + log_prio = PROTOCOL; else if (!strcasecmp(value, "notice")) log_prio = NOTICE; else if (!strcasecmp(value, "warning")) diff --git a/src/options.c b/src/options.c index e287580..0b911bc 100644 --- a/src/options.c +++ b/src/options.c @@ -59,10 +59,11 @@ static struct opt options[OPT_MAX+1] = { OPT(OT_PATH, .str = POTD_LOGFILE, "log-file", "specify a logfile path\n", NULL), OPT(OT_STR, .str = "notice", "log-level", "set the loglevel\n", - "error - log only errors\n" - "warning - log errors,warnings\n" - "notice - log errors,warnings,notices\n" - "debug - log all messages\n"), + "error - log only errors\n" + "warning - log errors,warnings\n" + "notice - log errors,warnings,notices\n" + "protocol - log errors,warnings,notices,protocol\n" + "debug - log all messages\n"), OPT_NOARG("daemon", "fork into background if possible\n", NULL), OPT_LIST(OT_STR, .str = NULL, "redirect", "setup redirector service\n", "format [listen]:[forward-to-protocol]\n" @@ -252,6 +253,7 @@ static void usage(const char *arg0, int print_copyright) char buf_help[BUFSIZ]; char value[32]; + (void) print_copyright; #ifdef HAVE_CONFIG_H if (print_copyright) fprintf(stderr, "\n%s (C) 2018 Toni Uhlig <%s>\n\n", diff --git a/src/protocol_ssh.c b/src/protocol_ssh.c index 63c46ba..63bd579 100644 --- a/src/protocol_ssh.c +++ b/src/protocol_ssh.c @@ -129,7 +129,9 @@ int ssh_init_cb(protocol_ctx *ctx) ctx->src.data = d; ssh_set_log_callback(ssh_log_cb); - ssh_set_log_level(SSH_LOG_FUNCTIONS); + //ssh_set_log_level(SSH_LOG_FUNCTIONS); + //ssh_set_log_level(SSH_LOG_PROTOCOL); + ssh_set_log_level(SSH_LOG_PACKET); if (!d->sshbind) return 1; @@ -381,12 +383,8 @@ static void ssh_log_cb(int priority, const char *function, switch (priority) { case 0: W("libssh: %s", buffer); - break; - case 1: - N("libssh: %s", buffer); - break; default: - D("libssh: %s", buffer); + P("libssh: %s", buffer); break; } } |