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.

58 lines
2.1 KiB

  1. //========= Copyright � Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Forward server log lines to remote listeners. Holds all log lines
  4. // for this map, up to a maximum.
  5. //
  6. //=============================================================================//
  7. #pragma once
  8. class CServerLogHTTPDispatcher : public CAutoGameSystemPerFrame
  9. {
  10. public:
  11. CServerLogHTTPDispatcher();
  12. bool LogForHTTPListeners( const char* szLogLine );
  13. void AddListener( const char* szURI );
  14. void RemoveAllListeners( void );
  15. void DumpListenersToConsole( void ) const;
  16. // base class overrides
  17. virtual void Shutdown() OVERRIDE;
  18. virtual void LevelInitPreEntity() OVERRIDE;
  19. virtual void LevelShutdownPreEntity() OVERRIDE;
  20. // Dispatch to listeners that need updates
  21. // Runs once per server frame, even if server is paused (ie not ticking)
  22. virtual void PreClientUpdate() OVERRIDE;
  23. struct LogLineStartForTick_t
  24. {
  25. LogLineStartForTick_t( int32 _iTick, size_t _unOffsetStart, size_t _unLength ) :
  26. iTick( _iTick ), unOffsetStart( _unOffsetStart ), unLength( _unLength ) { }
  27. int32 iTick;
  28. size_t unOffsetStart; // Offset from start of m_strServerLog storage
  29. size_t unLength; // Length of lines for this tick in characters
  30. };
  31. typedef CUtlLinkedList< LogLineStartForTick_t > LogLinesList_t;
  32. private:
  33. void Reset( void );
  34. void BuildTimestampString( void );
  35. CUtlVector< class CServerLogDestination* > m_vecListeners; // addresses requesting the server log with server tick they last ack'd
  36. LogLinesList_t m_llLogPerTick; // Linked list of log lines recorded for a tick. Has offsets in to m_strServerLog storage to find the start of the lines.
  37. CUtlStringBuilder m_strLogLinesThisTick; // Log lines being gathered this tick
  38. CUtlStringBuilder m_strServerLog; // String of all log lines since last map transition.
  39. #if defined DBGFLAG_ASSERT // DBG only safety check, nobody should be editing the list while we still have listeners holding on to LL handles
  40. LogLinesList_t::IndexType_t m_dbgLastAllocedHandle;
  41. #endif
  42. time_t m_localTimeLoggingStart;
  43. double m_loggingStartPlatTime;
  44. CUtlString m_strTimeStampPrefix;
  45. };
  46. CServerLogHTTPDispatcher* GetServerLogHTTPDispatcher( void );