aboutsummaryrefslogtreecommitdiff
path: root/src/libparsec/include/utl_logfile.h
blob: ffd44cb4bcfdff0f33c0618d4953b03963c63843 (plain)
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
/*
 * PARSEC HEADER: utl_logfile.h
 */

#ifndef _UTL_LOGFILE_H_
#define _UTL_LOGFILE_H_

// max. length of temporary buffer --------------------------------------------
//
#define MAX_LOG_BUFFER_LEN		4096

// class for logging information ----------------------------------------------
//
class UTL_LogFile
{
protected:
	char		m_szBuffer[ MAX_LOG_BUFFER_LEN + 1 ];
	size_t		m_nBufferLen;
	FILE*		m_pFile;
	refframe_t	m_LastFlushRefframe;

protected:

	// add an entry to the logfile
	void _AddEntry( const char* szEntry, size_t len2 );

public:
	
	// standard ctor
	UTL_LogFile( const char* szFilename = NULL );

	// standard dtor
	~UTL_LogFile();

	// open the logfile
	int Open( const char* szFilename );

	// printf like adding to the logfile
	int printf( const char *format, ... );

	// flush the buffer to the disk file
	void Flush();
};


// external functions ---------------------------------------------------------
//

// flush all registerd logfiles
void UTL_FlushRegisteredLogfiles();


#endif // !_UTL_LOGFILE_H_