aboutsummaryrefslogtreecommitdiff
path: root/libssh
diff options
context:
space:
mode:
authorAndreas Schneider <mail@cynapses.org>2009-05-05 07:19:50 +0000
committerAndreas Schneider <mail@cynapses.org>2009-05-05 07:19:50 +0000
commit1d78b6d00eac5a8a8d5f58f78189a3ce9639d926 (patch)
tree99606a6cf5879ec320ac9f2b7e6a4438e09ca863 /libssh
parent4c7879396140d7983b73da037a219c106ae47d86 (diff)
downloadlibssh-1d78b6d00eac5a8a8d5f58f78189a3ce9639d926.tar.gz
libssh-1d78b6d00eac5a8a8d5f58f78189a3ce9639d926.tar.xz
libssh-1d78b6d00eac5a8a8d5f58f78189a3ce9639d926.zip
Improve ssh_log().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@717 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh')
-rw-r--r--libssh/log.c70
1 files changed, 41 insertions, 29 deletions
diff --git a/libssh/log.c b/libssh/log.c
index d38a2bc..0ceff94 100644
--- a/libssh/log.c
+++ b/libssh/log.c
@@ -23,45 +23,57 @@
* vim: ts=2 sw=2 et cindent
*/
-#include "libssh/priv.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
-/** \defgroup ssh_log SSH Logging
- * \brief Logging functions for debugging and problem resolving
+#include "libssh/priv.h"
+
+/**
+ * @defgroup ssh_log SSH Logging
+ *
+ * @brief Logging functions for debugging and problem resolving
*/
/** \addtogroup ssh_log
* @{ */
-/** \brief logs an event
- * \param session the SSH session
- * \param verbosity verbosity of the event
- * \param format format string of the log entry
+/**
+ * @brief Log a SSH event.
+ *
+ * @param session The SSH session.
+ *
+ * @param verbosity The verbosity of the event.
+ *
+ * @param format The format string of the log entry.
*/
void ssh_log(SSH_SESSION *session, int verbosity, const char *format, ...) {
- char buffer[1024];
- char buf2[256];
- int min;
- va_list va;
- if(verbosity <= session->log_verbosity){
- va_start(va,format);
- vsnprintf(buffer,sizeof(buffer),format,va);
- va_end(va);
- if(session->options->log_function)
- session->options->log_function(buffer,session,verbosity);
- else if(verbosity==SSH_LOG_FUNCTIONS){
- if(session->log_indent > 255)
- min=255;
- else
- min=session->log_indent;
- memset(buf2,' ',min);
- buf2[min]=0;
- fprintf(stderr,"[func] %s%s\n",buf2,buffer);
- } else {
- fprintf(stderr,"[%d] %s\n",verbosity,buffer);
- }
- }
+ char buffer[1024];
+ char indent[256];
+ int min;
+ va_list va;
+
+ if (verbosity <= session->log_verbosity) {
+ va_start(va, format);
+ vsnprintf(buffer, sizeof(buffer), format, va);
+ va_end(va);
+
+ if (session->options->log_function) {
+ session->options->log_function(buffer, session, verbosity);
+ } else if (verbosity == SSH_LOG_FUNCTIONS) {
+ if (session->log_indent > 255) {
+ min = 255;
+ } else {
+ min = session->log_indent;
+ }
+
+ memset(indent, ' ', min);
+ indent[min] = '\0';
+
+ fprintf(stderr, "[func] %s%s\n", buf2, buffer);
+ } else {
+ fprintf(stderr, "[%d] %s\n", verbosity, buffer);
+ }
+ }
}
/** @} */