mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-10 18:28:10 +09:00
log: Split do_ssh_log().
This commit is contained in:
@@ -272,6 +272,9 @@ void ssh_log_common(struct ssh_common_struct *common,
|
|||||||
int verbosity,
|
int verbosity,
|
||||||
const char *function,
|
const char *function,
|
||||||
const char *format, ...) PRINTF_ATTRIBUTE(4, 5);
|
const char *format, ...) PRINTF_ATTRIBUTE(4, 5);
|
||||||
|
void ssh_log_function(int verbosity,
|
||||||
|
const char *function,
|
||||||
|
const char *buffer);
|
||||||
|
|
||||||
|
|
||||||
/** Free memory space */
|
/** Free memory space */
|
||||||
|
|||||||
27
src/log.c
27
src/log.c
@@ -66,6 +66,22 @@ static int current_timestring(int hires, char *buf, size_t len)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ssh_log_function(int verbosity,
|
||||||
|
const char *function,
|
||||||
|
const char *buffer)
|
||||||
|
{
|
||||||
|
char date[64] = {0};
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = current_timestring(1, date, sizeof(date));
|
||||||
|
if (rc == 0) {
|
||||||
|
fprintf(stderr, "[%s, %d] %s", date, verbosity, function);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "[%d] %s", verbosity, function);
|
||||||
|
}
|
||||||
|
fprintf(stderr, " %s\n", buffer);
|
||||||
|
}
|
||||||
|
|
||||||
/** @internal
|
/** @internal
|
||||||
* @brief do the actual work of logging an event
|
* @brief do the actual work of logging an event
|
||||||
*/
|
*/
|
||||||
@@ -74,9 +90,6 @@ static void do_ssh_log(struct ssh_common_struct *common,
|
|||||||
int verbosity,
|
int verbosity,
|
||||||
const char *function,
|
const char *function,
|
||||||
const char *buffer) {
|
const char *buffer) {
|
||||||
char date[64] = {0};
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
if (common->callbacks && common->callbacks->log_function) {
|
if (common->callbacks && common->callbacks->log_function) {
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
@@ -89,13 +102,7 @@ static void do_ssh_log(struct ssh_common_struct *common,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = current_timestring(1, date, sizeof(date));
|
ssh_log_function(verbosity, function, buffer);
|
||||||
if (rc == 0) {
|
|
||||||
fprintf(stderr, "[%s, %d] %s", date, verbosity, function);
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "[%d] %s", verbosity, function);
|
|
||||||
}
|
|
||||||
fprintf(stderr, " %s\n", buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* legacy function */
|
/* legacy function */
|
||||||
|
|||||||
Reference in New Issue
Block a user