aboutsummaryrefslogtreecommitdiff
path: root/libssh
diff options
context:
space:
mode:
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);
+ }
+ }
}
/** @} */