/*********************************************************************
 * This file is part of the cpplibs suite.
 *
 * Copyright (C) 2001 Topi Mäenpää
 * All rights reserved.
 *
 * This program is free software. You can redistribute and/or modify
 * it under the terms of the free software licence found in the
 * accompanying file "COPYING". The licence terms must always be
 * redistributed with this source file. The above copyright notice
 * must be reproduced in all modified and unmodified copies of this
 * source file.
 *
 * $Revision: 1.4 $
 *********************************************************************/

#ifndef _LOGFILE_H
#define _LOGFILE_H

#include <fstream>
#include <string>
#include "../Mutex.h"

namespace util { namespace io {
	/**
	 * A class for writing log files. LogFile writes messages to a file,
	 * and adds a time stamp to each printed message. The implementation
	 * is MT-safe.
	 **/
	class LogFile
	{
	public:
		/**
		 * Create a new log file.
		 * @param filename the name of the file
		 * @exception IOException if the file cannot be written to
		 **/
		LogFile(char* fileName);
		~LogFile();

		void log(const std::string& msg);
		void log(const char* msg);

	private:
		std::ofstream logFile;
		util::Mutex logMutex;
	};
}}

#endif
