
#ifndef LOG_H
#define LOG_H

// A Logging System
// Author: Jörg Haeger, 27.05.1999

#include <pthread.h>
#include <stdio.h>

class Log
{
public:
	Log();

	// conditional logging of debug messages
	void debug(const char *tag, const char *format, ...);

	// logging import messages
	void put(const char *format, ...);

	// logging all messages
	void putv(const char *format, ...);

	void start(int putvToStdOut = 0);
private:
	void writeLine(char *line, FILE *aFile,
		char *lastLine, int &counter);

	pthread_mutex_t mutex;
	FILE *file, *vFile;
	int active;
	char lastLine[1024], lastVerboseLine[1024];
	int counter, vCounter;
};

extern Log log;

#endif
