7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 00:21:31 +00:00

Add some logging to KINNG

This commit is contained in:
Jon Evans 2024-11-05 18:38:27 -05:00
parent c3fb1445c7
commit 420ea9da9d
2 changed files with 32 additions and 1 deletions
include/api
libs/kinng/src

View File

@ -86,7 +86,7 @@ struct PLUGIN_ACTION
wxString identifier;
wxString name;
wxString description;
bool show_button;
bool show_button = false;
wxString entrypoint;
std::set<PLUGIN_ACTION_SCOPE> scopes;
std::vector<wxString> args;

View File

@ -21,6 +21,14 @@
#include <kinng.h>
#include <nng/nng.h>
#include <nng/protocol/reqrep0/rep.h>
#include <wx/log.h>
/**
* Trace nng server debug output
* @ingroup trace_env_vars
*/
static const wxChar TraceNng[] = wxT( "KINNG" );
KINNG_REQUEST_SERVER::KINNG_REQUEST_SERVER( const std::string& aSocketUrl ) :
@ -80,20 +88,33 @@ void KINNG_REQUEST_SERVER::listenThread()
nng_listener listener;
int retCode = 0;
wxLogTrace( TraceNng, wxS( "KINNG_REQUEST_SERVER starting" ) );
retCode = nng_rep0_open( &socket );
if( retCode != 0 )
{
wxLogTrace( TraceNng,
wxString::Format( wxS( "Got error code %d from nng_rep0_open!" ), retCode ) );
return;
}
retCode = nng_listener_create( &listener, socket, m_socketUrl.c_str() );
if( retCode != 0 )
{
wxLogTrace( TraceNng,
wxString::Format( wxS( "Got error code %d from nng_listener_create!" ),
retCode ) );
return;
}
nng_socket_set_ms( socket, NNG_OPT_RECVTIMEO, 500 );
nng_listener_start( listener, 0 );
wxLogTrace( TraceNng, wxS( "KINNG_REQUEST_SERVER listener has started" ) );
while( !m_shutdown.load() )
{
char* buf = nullptr;
@ -108,6 +129,8 @@ void KINNG_REQUEST_SERVER::listenThread()
if( retCode != 0 )
{
nng_free( buf, sz );
wxLogTrace( TraceNng,
wxString::Format( wxS( "Got error code %d from nngc_recv!" ), retCode ) );
break;
}
@ -122,8 +145,16 @@ void KINNG_REQUEST_SERVER::listenThread()
retCode = nng_send( socket, const_cast<std::string::value_type*>( m_pendingReply.c_str() ),
m_pendingReply.length(), 0 );
if( retCode != 0 )
{
wxLogTrace( TraceNng,
wxString::Format( wxS( "Got error code %d from nng_send!" ), retCode ) );
}
m_pendingReply.clear();
}
wxLogTrace( TraceNng, wxS( "KINNG_REQUEST_SERVER shutting down" ) );
nng_close( socket );
}