mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-04 23:02:02 +01:00
log socket address to try to track down apparent misaddressing
This commit is contained in:
parent
e80fe76652
commit
1638d964fb
1 changed files with 19 additions and 4 deletions
|
@ -51,6 +51,7 @@
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#if defined(__FreeBSD__)
|
||||||
# if (OSVERSION > 500000)
|
# if (OSVERSION > 500000)
|
||||||
|
@ -90,8 +91,8 @@ static int s_nSpawns = 0;
|
||||||
static int g_maxsocks = -1;
|
static int g_maxsocks = -1;
|
||||||
static int g_udpsock = -1;
|
static int g_udpsock = -1;
|
||||||
|
|
||||||
void
|
static bool
|
||||||
logf( XW_LogLevel level, const char* format, ... )
|
willLog( XW_LogLevel level )
|
||||||
{
|
{
|
||||||
RelayConfigs* rc = RelayConfigs::GetConfigs();
|
RelayConfigs* rc = RelayConfigs::GetConfigs();
|
||||||
int configLevel = level;
|
int configLevel = level;
|
||||||
|
@ -103,7 +104,13 @@ logf( XW_LogLevel level, const char* format, ... )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( level <= configLevel ) {
|
return level <= configLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
logf( XW_LogLevel level, const char* format, ... )
|
||||||
|
{
|
||||||
|
if ( willLog( level ) ) {
|
||||||
#ifdef USE_SYSLOG
|
#ifdef USE_SYSLOG
|
||||||
char buf[256];
|
char buf[256];
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -118,6 +125,7 @@ logf( XW_LogLevel level, const char* format, ... )
|
||||||
bool useFile;
|
bool useFile;
|
||||||
char logFile[256];
|
char logFile[256];
|
||||||
|
|
||||||
|
RelayConfigs* rc = RelayConfigs::GetConfigs();
|
||||||
useFile = rc->GetValueFor( "LOGFILE_PATH", logFile, sizeof(logFile) );
|
useFile = rc->GetValueFor( "LOGFILE_PATH", logFile, sizeof(logFile) );
|
||||||
|
|
||||||
if ( useFile ) {
|
if ( useFile ) {
|
||||||
|
@ -451,7 +459,14 @@ send_via_udp( int socket, const struct sockaddr *dest_addr,
|
||||||
if ( 0 > nSent ) {
|
if ( 0 > nSent ) {
|
||||||
logf( XW_LOGERROR, "sendmsg->errno %d (%s)", errno, strerror(errno) );
|
logf( XW_LOGERROR, "sendmsg->errno %d (%s)", errno, strerror(errno) );
|
||||||
}
|
}
|
||||||
logf( XW_LOGINFO, "%s()=>%d", __func__, nSent );
|
|
||||||
|
XW_LogLevel level = XW_LOGINFO;
|
||||||
|
if ( willLog( level ) ) {
|
||||||
|
gchar* b64 = g_base64_encode( (unsigned char*)dest_addr, sizeof(dest_addr) );
|
||||||
|
logf( level, "%s()=>%d; addr=%s", __func__, nSent, b64 );
|
||||||
|
g_free( b64 );
|
||||||
|
}
|
||||||
|
|
||||||
return nSent;
|
return nSent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue