1

我正在编写一个使用 libssh 的应用程序,它默认记录到 stderr。我想捕获日志记录,以便我可以用它做一些有用的事情。

Libssh 似乎为此目的提供了一些功能,但我似乎无法让它们工作。文档是有限的,我似乎找不到太多东西。

libssh/callbacks.h 中提供的函数在此处int ssh_set_log_callback ( ssh_logging_callback cb )记录。

ssh_logging_callback记录在这里

我的应用程序中有以下代码:

static void ssh_log_function(int priority, const char *function, const char *buffer, void *userdata)
{
    cout << priority << " " << function << endl << buffer << endl;
    cout << "And now for something completely different" << endl;
}

然后稍后在我的应用程序中,在我执行一些 libssh 命令之前,我有这个:

ssh_set_log_callback(ssh_log_function);

当我编译和执行时,我得到了 stderr 的常用日志输出,并且没有我创建的函数正在运行的迹象。

我错过了什么还是我做错了?我也尝试过传递 &ssh_log_function ,但没有任何区别。

将不胜感激任何帮助!谢谢!

4

1 回答 1

1

For anyone interested, I managed to get this working and the above code works. I was simply setting the log level to an uninitialised integer later on in my code. /Fail

Hope this helps someone else.

于 2014-06-12T01:10:13.243 回答