From d0e6c34ed07d332c070fa6387e36bc1e517d486f Mon Sep 17 00:00:00 2001 From: "Artyom V. Poptsov" Date: Sun, 21 May 2017 19:56:41 +0300 Subject: log.c (_gssh_log_warning): New procedure * libguile-ssh/log.c (_gssh_log_warning): New procedure. * libguile-ssh/log.h: Likewise. * libguile-ssh/channel-func.c (guile_ssh_channel_get_exit_status): Issue a warning if 'ssh_channel_get_exit_status' failed to get the exit status. --- libguile-ssh/channel-func.c | 6 ++++++ libguile-ssh/log.c | 15 +++++++++++++++ libguile-ssh/log.h | 3 +++ 3 files changed, 24 insertions(+) diff --git a/libguile-ssh/channel-func.c b/libguile-ssh/channel-func.c index b68d217..f657102 100644 --- a/libguile-ssh/channel-func.c +++ b/libguile-ssh/channel-func.c @@ -26,6 +26,7 @@ #include #include "common.h" +#include "log.h" #include "error.h" #include "channel-type.h" #include "session-type.h" @@ -106,6 +107,11 @@ returned (yet). \ GSSH_VALIDATE_OPEN_CHANNEL (channel, SCM_ARG1, FUNC_NAME); res = ssh_channel_get_exit_status (cd->ssh_channel); + if (res == SSH_ERROR) { + _gssh_log_warning (FUNC_NAME, + "Could not get exit status", + channel); + } return (res == SSH_ERROR) ? SCM_BOOL_F : scm_from_int (res); } #undef FUNC_NAME diff --git a/libguile-ssh/log.c b/libguile-ssh/log.c index c631306..6588749 100644 --- a/libguile-ssh/log.c +++ b/libguile-ssh/log.c @@ -255,6 +255,21 @@ _gssh_log_error (const char* function_name, const char* msg, SCM args) scm_dynwind_end (); } +void +_gssh_log_warning (const char* function_name, const char* msg, SCM args) +{ + char *c_str; + scm_dynwind_begin (0); + + c_str = scm_to_locale_string (scm_object_to_string (args, SCM_UNDEFINED)); + scm_dynwind_free (c_str); + + _ssh_log (SSH_LOG_WARNING, function_name, "[GSSH WARNING] %s: %s", + msg, c_str); + + scm_dynwind_end (); +} + /* Initialization */ diff --git a/libguile-ssh/log.h b/libguile-ssh/log.h index b4ffbb0..ee0324a 100644 --- a/libguile-ssh/log.h +++ b/libguile-ssh/log.h @@ -21,6 +21,9 @@ extern struct symbol_mapping log_verbosity[]; extern void _gssh_log_error (const char* function_name, const char* msg, SCM args); +extern void _gssh_log_warning (const char* function_name, const char* msg, + SCM args); + extern void init_log_func (void); /* log.h ends here */ -- cgit v1.2.3