/*
	ZazouMiniWebServer

	Copyright (C) 2003-2011 Xavier Garreau <xavier@xgarreau.org>

	This file is part of ZazouMiniWebServer.

    ZazouMiniWebServer is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    ZazouMiniWebServer is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ZazouMiniWebServer; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/

#ifndef _ZMWSLOGGER_H
#define _ZMWSLOGGER_H 1

#include <string>
#include <map>
#include <fstream>

#include "threadpool.h"

class ZMWSLoggerRequest : public ZRequest
{
public:
	std::string logFile;
	std::string logLine;

	ZMWSLoggerRequest(const std::string& lf, const std::string& ll) : logFile(lf), logLine(ll) {}
	~ZMWSLoggerRequest() {}
};

class ZMWSLoggerThread : public ZThread {
public:
	ZMWSLoggerThread() {}
	~ZMWSLoggerThread() {}
protected:
	void handle_request(ZRequest* r);
};

typedef std::map<std::string, std::ofstream*> logfilesmap_t;
typedef logfilesmap_t::iterator logfilesmap_iterator;
class ZMWSLogger 
{
	ZThreadPool<ZMWSLoggerThread>* ztp;
	logfilesmap_t logfilesmap;
	ZMWSLogger();
	~ZMWSLogger();
public:
	static void LogIt(const std::string& file, const std::string line);
};

#endif