mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-06 10:27:22 +09:00
log: add ssh_vlog to save the stack space
and add LOG_SIZE macro to control the buffer size Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Change-Id: I3eaeea001fc531fdb55074fc3a9d140b27847c1f
This commit is contained in:
@@ -49,6 +49,8 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* Visual Studio hasn't inttypes.h so it doesn't know uint32_t */
|
||||
typedef int int32_t;
|
||||
@@ -587,6 +589,10 @@ LIBSSH_API int ssh_set_log_level(int level);
|
||||
LIBSSH_API int ssh_get_log_level(void);
|
||||
LIBSSH_API void *ssh_get_log_userdata(void);
|
||||
LIBSSH_API int ssh_set_log_userdata(void *data);
|
||||
LIBSSH_API void ssh_vlog(int verbosity,
|
||||
const char *function,
|
||||
const char *format,
|
||||
va_list *va) PRINTF_ATTRIBUTE(3, 0);
|
||||
LIBSSH_API void _ssh_log(int verbosity,
|
||||
const char *function,
|
||||
const char *format, ...) PRINTF_ATTRIBUTE(3, 4);
|
||||
|
||||
@@ -369,13 +369,11 @@ public:
|
||||
return state;
|
||||
}
|
||||
void log(int priority, const char *format, ...){
|
||||
char buffer[1024];
|
||||
va_list va;
|
||||
|
||||
va_start(va, format);
|
||||
vsnprintf(buffer, sizeof(buffer), format, va);
|
||||
ssh_vlog(priority, "libsshpp", format, &va);
|
||||
va_end(va);
|
||||
_ssh_log(priority, "libsshpp", "%s", buffer);
|
||||
}
|
||||
|
||||
/** @brief copies options from a session to another
|
||||
|
||||
Reference in New Issue
Block a user