summaryrefslogtreecommitdiff
path: root/engine/sv_log.h
blob: 42f05113565356177291178559c09cb060c28230 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//
//=============================================================================//
// sv_log.h
// Server logging functions

#ifndef SV_LOG_H
#define SV_LOG_H
#pragma once

#include <igameevents.h>
#include "netadr.h"

class CLog : public IGameEventListener2
{
public:
	CLog();
	virtual ~CLog();

public: // IGameEventListener Interface
	
	void FireGameEvent( IGameEvent *event );

public: 

	bool IsActive( void );	// true if logging is "on"
	void SetLoggingState( bool state );	// set the logging state to true (on) or false (off)
	
	bool UsingLogAddress( void );
	bool AddLogAddress(netadr_t addr);
	bool DelLogAddress(netadr_t addr);
	void DelAllLogAddress( void );
	void ListLogAddress( void );
	
	netadr_t GetLogAddress();
	
	void Open( void );  // opens logging file
	void Close( void );	// closes logging file
	void Flush( void ); // flushes the log file to disk

	void Init( void );
	void Reset( void );	// reset all logging streams
	void Shutdown( void );
	
	void Printf( PRINTF_FORMAT_STRING const char *fmt, ... ) FMTFUNCTION( 2, 3 );	// log a line to log file
	void Print( const char * text );
	void PrintServerVars( void ); // prints server vars to log file

	void RunFrame();

private:

	bool m_bActive;		// true if we're currently logging

	CUtlVector< netadr_t >	m_LogAddresses;		// Server frag log stream is sent to the address(es) in this list
	FileHandle_t			m_hLogFile;			// File where frag log is put.
	CUtlString				m_LogFilename;		// Name of our logfile.
	double					m_flLastLogFlush;
	bool					m_bFlushLog;
};

extern CLog g_Log;

#endif // SV_LOG_H