Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4 KiB

  1. //============ Copyright (c) Valve Corporation, All rights reserved. ============
  2. //
  3. // Tier1 logging helpers.
  4. //
  5. //===============================================================================
  6. #include "tier1_logging.h"
  7. CBufferedLoggingListener::CBufferedLoggingListener() :
  8. m_StoredSpew( 0, 512, 0 )
  9. {
  10. }
  11. void CBufferedLoggingListener::Log( const LoggingContext_t *pContext, const tchar *pMessage )
  12. {
  13. m_StoredSpew.PutInt( pContext->m_ChannelID );
  14. m_StoredSpew.PutInt( pContext->m_Severity );
  15. m_StoredSpew.PutChar( pContext->m_Color.r() );
  16. m_StoredSpew.PutChar( pContext->m_Color.g() );
  17. m_StoredSpew.PutChar( pContext->m_Color.b() );
  18. m_StoredSpew.PutChar( pContext->m_Color.a() );
  19. m_StoredSpew.PutString( pMessage );
  20. }
  21. void CBufferedLoggingListener::EmitBufferedSpew()
  22. {
  23. while ( m_StoredSpew.GetBytesRemaining() > 0 )
  24. {
  25. LoggingChannelID_t channelID = m_StoredSpew.GetInt();
  26. LoggingSeverity_t severity = ( LoggingSeverity_t )m_StoredSpew.GetInt();
  27. unsigned char r, g, b, a;
  28. r = m_StoredSpew.GetChar();
  29. g = m_StoredSpew.GetChar();
  30. b = m_StoredSpew.GetChar();
  31. a = m_StoredSpew.GetChar();
  32. Color color( r, g, b, a );
  33. int nLen = m_StoredSpew.PeekStringLength();
  34. if ( nLen )
  35. {
  36. char *pMessage = ( char * )stackalloc( nLen );
  37. m_StoredSpew.GetString( pMessage, nLen );
  38. LoggingSystem_LogDirect( channelID, severity, color, pMessage );
  39. }
  40. }
  41. m_StoredSpew.Clear();
  42. }