mirror of
https://github.com/ValveSoftware/GameNetworkingSockets.git
synced 2026-05-29 16:20:34 +00:00
test_p2p: add --loglevel-p2prendezvous
This commit is contained in:
+8
-6
@@ -28,7 +28,7 @@ int g_nVirtualPortLocal = 0; // Used when listening, and when connecting
|
||||
int g_nVirtualPortRemote = 0; // Only used when connecting
|
||||
ESteamNetworkingSocketsDebugOutputType g_eTestP2PRendezvousLogLevel = k_ESteamNetworkingSocketsDebugOutputType_Verbose;
|
||||
|
||||
static ESteamNetworkingSocketsDebugOutputType ParseSpewLevel( const char *pszArg )
|
||||
static ESteamNetworkingSocketsDebugOutputType ParseLogLevelValue( const char *pszArg, const char *pszSwitchName )
|
||||
{
|
||||
if ( !strcmp( pszArg, "msg" ) )
|
||||
return k_ESteamNetworkingSocketsDebugOutputType_Msg;
|
||||
@@ -37,7 +37,7 @@ static ESteamNetworkingSocketsDebugOutputType ParseSpewLevel( const char *pszArg
|
||||
if ( !strcmp( pszArg, "debug" ) )
|
||||
return k_ESteamNetworkingSocketsDebugOutputType_Debug;
|
||||
|
||||
TEST_Fatal( "Invalid --spewlevel '%s'. Expected one of: msg, verbose, debug", pszArg );
|
||||
TEST_Fatal( "Invalid %s '%s'. Expected one of: msg, verbose, debug", pszSwitchName, pszArg );
|
||||
return k_ESteamNetworkingSocketsDebugOutputType_Msg;
|
||||
}
|
||||
|
||||
@@ -203,11 +203,13 @@ int main( int argc, const char **argv )
|
||||
else if ( !strcmp( pszSwitch, "--spewlevel" ) || !strncmp( pszSwitch, "--spewlevel=", 12 ) )
|
||||
{
|
||||
const char *pszArg = pszSwitch[11] == '=' ? pszSwitch + 12 : GetArg();
|
||||
ESteamNetworkingSocketsDebugOutputType eLogLevel = ParseSpewLevel( pszArg );
|
||||
ESteamNetworkingSocketsDebugOutputType eLogLevel = ParseLogLevelValue( pszArg, "--spewlevel" );
|
||||
TEST_SetStdoutDetailLevel( eLogLevel );
|
||||
g_eTestP2PRendezvousLogLevel = ( eLogLevel >= k_ESteamNetworkingSocketsDebugOutputType_Debug )
|
||||
? k_ESteamNetworkingSocketsDebugOutputType_Debug
|
||||
: k_ESteamNetworkingSocketsDebugOutputType_Verbose;
|
||||
}
|
||||
else if ( !strcmp( pszSwitch, "--loglevel-p2prendezvous" ) || !strncmp( pszSwitch, "--loglevel-p2prendezvous=", 25 ) )
|
||||
{
|
||||
const char *pszArg = pszSwitch[24] == '=' ? pszSwitch + 25 : GetArg();
|
||||
g_eTestP2PRendezvousLogLevel = ParseLogLevelValue( pszArg, "--loglevel-p2prendezvous" );
|
||||
}
|
||||
else
|
||||
TEST_Fatal( "Unexpected command line argument '%s'", pszSwitch );
|
||||
|
||||
@@ -18,9 +18,11 @@ g_failed = False
|
||||
g_server_ready = threading.Event()
|
||||
g_server_startup_timeout = 3 # seconds
|
||||
g_spew_level = None
|
||||
g_p2p_rendezvous_level = None
|
||||
|
||||
def ParseArgs():
|
||||
global g_spew_level
|
||||
global g_p2p_rendezvous_level
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
@@ -28,8 +30,15 @@ def ParseArgs():
|
||||
choices=[ 'msg', 'verbose', 'debug' ],
|
||||
help='Control how much diagnostic spew is mirrored to stdio. More detailed output is always available in the per-process file logs.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--loglevel-p2prendezvous',
|
||||
dest='loglevel_p2prendezvous',
|
||||
choices=[ 'msg', 'verbose', 'debug' ],
|
||||
help='Control detail level specifically for P2P rendezvous-related spew.'
|
||||
)
|
||||
args = parser.parse_args()
|
||||
g_spew_level = args.spewlevel
|
||||
g_p2p_rendezvous_level = args.loglevel_p2prendezvous
|
||||
|
||||
# Thread class that runs a process and captures its output
|
||||
class RunProcessInThread(threading.Thread):
|
||||
@@ -120,6 +129,8 @@ def StartClientInThread( role, local, remote ):
|
||||
|
||||
if g_spew_level is not None:
|
||||
cmdline.append( '--spewlevel=' + g_spew_level )
|
||||
if g_p2p_rendezvous_level is not None:
|
||||
cmdline.append( '--loglevel-p2prendezvous=' + g_p2p_rendezvous_level )
|
||||
|
||||
env = dict( os.environ )
|
||||
if os.name == 'nt' and not os.path.exists( 'steamnetworkingsockets.dll' ) and not os.path.exists( 'GameNetworkingSockets.dll' ):
|
||||
|
||||
Reference in New Issue
Block a user