diff options
author | Xiang Xiao <xiaoxiang@xiaomi.com> | 2021-05-10 19:27:31 +0800 |
---|---|---|
committer | Jakub Jelen <jjelen@redhat.com> | 2021-06-10 14:56:29 +0200 |
commit | 14276f0b516f0bec63d8a737dba97334c68e528c (patch) | |
tree | 14b197aaedb3cf4c2de56918d9d3a74b79f37ca5 /include/libssh | |
parent | 672c1f8a3a3ee9b76283583df1e9d1f4fd0a8d17 (diff) | |
download | libssh-14276f0b516f0bec63d8a737dba97334c68e528c.tar.gz libssh-14276f0b516f0bec63d8a737dba97334c68e528c.tar.xz libssh-14276f0b516f0bec63d8a737dba97334c68e528c.zip |
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
Diffstat (limited to 'include/libssh')
-rw-r--r-- | include/libssh/libssh.h | 6 | ||||
-rw-r--r-- | include/libssh/libsshpp.hpp | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index 4f401056..4bfd81ef 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -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); diff --git a/include/libssh/libsshpp.hpp b/include/libssh/libsshpp.hpp index 75c9c7a1..f792465c 100644 --- a/include/libssh/libsshpp.hpp +++ b/include/libssh/libsshpp.hpp @@ -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 |