diff options
author | Andreas Schneider <asn@cryptomilk.org> | 2013-07-14 12:36:59 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2013-07-14 12:36:59 +0200 |
commit | 2c91efcc68d9a6aff9163e81df7a5024703084d4 (patch) | |
tree | b9cadb84146bab8e7d2a27c4e153b5caf3f73bde /include | |
parent | 73309f19e582a712e78f54988fc51dbc5ab60bf4 (diff) | |
download | libssh-2c91efcc68d9a6aff9163e81df7a5024703084d4.tar.gz libssh-2c91efcc68d9a6aff9163e81df7a5024703084d4.tar.xz libssh-2c91efcc68d9a6aff9163e81df7a5024703084d4.zip |
log: Implment new logging functions.
Diffstat (limited to 'include')
-rw-r--r-- | include/libssh/callbacks.h | 34 | ||||
-rw-r--r-- | include/libssh/libssh.h | 6 | ||||
-rw-r--r-- | include/libssh/priv.h | 12 |
3 files changed, 47 insertions, 5 deletions
diff --git a/include/libssh/callbacks.h b/include/libssh/callbacks.h index bc3eb79e..7525b73d 100644 --- a/include/libssh/callbacks.h +++ b/include/libssh/callbacks.h @@ -75,6 +75,24 @@ typedef void (*ssh_log_callback) (ssh_session session, int priority, const char *message, void *userdata); /** + * @brief SSH log callback. + * + * All logging messages will go through this callback. + * + * @param priority Priority of the log, the smaller being the more important. + * + * @param function The function name calling the the logging fucntions. + * + * @param message The actual message + * + * @param userdata Userdata to be passed to the callback function. + */ +typedef void (*ssh_logging_callback) (int priority, + const char *function, + const char *buffer, + void *userdata); + +/** * @brief SSH Connection status callback. * @param session Current session handler * @param status Percentage of connection status, going from 0.0 to 1.0 @@ -798,6 +816,22 @@ LIBSSH_API struct ssh_threads_callbacks_struct *ssh_threads_get_pthread(void); */ LIBSSH_API struct ssh_threads_callbacks_struct *ssh_threads_get_noop(void); +/** + * @brief Set the logging callback function. + * + * @param[in] cb The callback to set. + * + * @return 0 on success, < 0 on errror. + */ +LIBSSH_API int ssh_set_log_callback(ssh_logging_callback cb); + +/** + * @brief Get the pointer to the logging callback function. + * + * @return The pointer the the callback or NULL if none set. + */ +LIBSSH_API ssh_logging_callback ssh_get_log_callback(void); + /** @} */ #ifdef __cplusplus } diff --git a/include/libssh/libssh.h b/include/libssh/libssh.h index dd736322..ce21ca46 100644 --- a/include/libssh/libssh.h +++ b/include/libssh/libssh.h @@ -418,6 +418,12 @@ LIBSSH_API int ssh_is_blocking(ssh_session session); LIBSSH_API int ssh_is_connected(ssh_session session); LIBSSH_API int ssh_is_server_known(ssh_session session); +/* LOGGING */ +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); + /* legacy */ LIBSSH_API void ssh_log(ssh_session session, int prioriry, diff --git a/include/libssh/priv.h b/include/libssh/priv.h index d7974026..35a6e4f3 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -152,15 +152,17 @@ struct ssh_kex_struct; int ssh_get_key_params(ssh_session session, ssh_key *privkey); /* LOGGING */ -#define SSH_LOG(session, priority, ...) \ - ssh_log_common(&session->common, priority, __FUNCTION__, __VA_ARGS__) +void _ssh_log(int verbosity, + const char *function, + const char *format, ...) PRINTF_ATTRIBUTE(3, 4); +#define SSH_LOG(priority, ...) \ + _ssh_log(priority, __FUNCTION__, __VA_ARGS__) + +/* LEGACY */ void ssh_log_common(struct ssh_common_struct *common, int verbosity, const char *function, const char *format, ...) PRINTF_ATTRIBUTE(4, 5); -void ssh_log_function(int verbosity, - const char *function, - const char *buffer); /* ERROR HANDLING */ |