diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /replay/spew.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'replay/spew.cpp')
| -rw-r--r-- | replay/spew.cpp | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/replay/spew.cpp b/replay/spew.cpp new file mode 100644 index 0000000..475f60f --- /dev/null +++ b/replay/spew.cpp @@ -0,0 +1,125 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#include "spew.h" +#include "dbg.h" +#include "strtools.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +//---------------------------------------------------------------------------------------- + +class CBlockSpewer : public ISpewer +{ + virtual void PrintBlockStart() const + { + Log( "\n********************************************************************************\n*\n" ); + } + + virtual void PrintBlockEnd() const + { + Log( "*\n********************************************************************************\n\n" ); + } + + virtual void PrintEmptyLine() const + { + Log( "*\n" ); + } + + virtual void PrintEventStartMsg( const char *pMsg ) const + { + char pDots[] = { "............................................." }; + const int nNumDots = MAX( 3, V_strlen( pDots ) - V_strlen( pMsg ) ); + pDots[ nNumDots ] = '\0'; + Log( "* %s%s", pMsg, pDots ); + } + + virtual void PrintEventResult( bool bSuccess ) const + { + Log( "%s\n", bSuccess ? "OK" : "FAILED" ); + } + + virtual void PrintEventError( const char *pError ) const + { + Log( "*\n*\n* ** ERROR: %s\n*\n", pError ); + } + + virtual void PrintTestHeader( const char *pHeader ) const + { + Log( "*\n*\n* %s...\n*\n", pHeader ); + } + + virtual void PrintValue( const char *pWhat, const char *pValue ) const + { + char pSpaces[] = { " " }; + const int nNumSpaces = MAX( 3, V_strlen( pSpaces ) - V_strlen( pWhat ) ); + pSpaces[ nNumSpaces ] = '\0'; + Log( "* %s: %s%s\n", pWhat, pSpaces, pValue ); + } + + virtual void PrintMsg( const char *pMsg ) const + { + Log( "* %s\n", pMsg ); + } +}; + +//---------------------------------------------------------------------------------------- + +static CBlockSpewer s_BlockSpewer; +ISpewer *g_pBlockSpewer = &s_BlockSpewer; + +//---------------------------------------------------------------------------------------- + +class CNullSpewer : public ISpewer +{ +public: + virtual void PrintBlockStart() const {} + virtual void PrintBlockEnd() const {} + virtual void PrintEmptyLine() const {} + virtual void PrintEventStartMsg( const char *pMsg ) const {} + virtual void PrintEventResult( bool bSuccess ) const {} + virtual void PrintTestHeader( const char *pHeader ) const {} + virtual void PrintMsg( const char *pMsg ) const {} + virtual void PrintValue( const char *pWhat, const char *pValue ) const {} + + virtual void PrintEventError( const char *pError ) const + { + Log( "\n\nERROR: %s\n\n", pError ); + } +}; + +//---------------------------------------------------------------------------------------- + +static CNullSpewer s_NullSpewer; +ISpewer *g_pNullSpewer = &s_NullSpewer; + +//---------------------------------------------------------------------------------------- + +class CSimpleSpewer : public CNullSpewer +{ +public: + virtual void PrintMsg( const char *pMsg ) const + { + Log( "%s", pMsg ); + } +}; + +//---------------------------------------------------------------------------------------- + +static CSimpleSpewer s_SimpleSpewer; +ISpewer *g_pSimpleSpewer = &s_SimpleSpewer; + +//---------------------------------------------------------------------------------------- + +ISpewer *g_pDefaultSpewer = g_pNullSpewer; + +//---------------------------------------------------------------------------------------- + +CBaseSpewer::CBaseSpewer( ISpewer *pSpewer/*=g_pDefaultSpewer*/ ) +: m_pSpewer( pSpewer ) +{ +} + +//---------------------------------------------------------------------------------------- |