#ifndef LOG_H
#define LOG_H

/*
 * @(#)Log.h
 *
 * This file is part of webCDwriter - Network CD Writing.
 *
 * Copyright (C) 1999-2002 Jörg P. M. Haeger
 *
 * webCDwriter is free software. See CDWserver.cpp for details.
 *
 * Jörg Haeger, 27.05.1999
 */

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

/**
 * A Logging System
 *
 * @version 20021026
 * @author Jörg P. M. Haeger
 */
class Log {
	pthread_mutex_t mutex;
	int counter;
	char lastLine[1024];
	FILE *outStream;

public:
	Log();

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

	/**
	 * log with respect to the current log level
	 */
	void put(int level, const char *format, ...);

	// log important messages
	void put(const char *format, ...);

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

	void start(int toStdOut = 0);

private:
	void writeLine(int level, char *line);
};

extern Log log;

#endif
