diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2011-09-17 11:05:17 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2011-09-17 11:05:17 +0200 |
commit | b96943e86142774871107a4f814573998e2c8048 (patch) | |
tree | 96ba02c2b881cdcce152eb581a9d3e6a412986e3 | |
parent | 569312f7bd8a45e9f9c33907e01ced04df60c104 (diff) | |
download | libssh-b96943e86142774871107a4f814573998e2c8048.tar.gz libssh-b96943e86142774871107a4f814573998e2c8048.tar.xz libssh-b96943e86142774871107a4f814573998e2c8048.zip |
log: Split do_ssh_log().
-rw-r--r-- | include/libssh/priv.h | 3 | ||||
-rw-r--r-- | src/log.c | 27 |
2 files changed, 20 insertions, 10 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 0ab371d1..aa22d10f 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -272,6 +272,9 @@ void ssh_log_common(struct ssh_common_struct *common, int verbosity, const char *function, const char *format, ...) PRINTF_ATTRIBUTE(4, 5); +void ssh_log_function(int verbosity, + const char *function, + const char *buffer); /** Free memory space */ @@ -66,6 +66,22 @@ static int current_timestring(int hires, char *buf, size_t len) return 0; } +void ssh_log_function(int verbosity, + const char *function, + const char *buffer) +{ + char date[64] = {0}; + int rc; + + rc = current_timestring(1, date, sizeof(date)); + if (rc == 0) { + fprintf(stderr, "[%s, %d] %s", date, verbosity, function); + } else { + fprintf(stderr, "[%d] %s", verbosity, function); + } + fprintf(stderr, " %s\n", buffer); +} + /** @internal * @brief do the actual work of logging an event */ @@ -74,9 +90,6 @@ static void do_ssh_log(struct ssh_common_struct *common, int verbosity, const char *function, const char *buffer) { - char date[64] = {0}; - int rc; - if (common->callbacks && common->callbacks->log_function) { char buf[1024]; @@ -89,13 +102,7 @@ static void do_ssh_log(struct ssh_common_struct *common, return; } - rc = current_timestring(1, date, sizeof(date)); - if (rc == 0) { - fprintf(stderr, "[%s, %d] %s", date, verbosity, function); - } else { - fprintf(stderr, "[%d] %s", verbosity, function); - } - fprintf(stderr, " %s\n", buffer); + ssh_log_function(verbosity, function, buffer); } /* legacy function */ |