


#ifndef __SYS_CLOG_H
#define __SYS_CLOG_H

#include <cstdio>
#include <iostream>
#include <fstream>
#include <string>

#define ENTETE "\"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\
<html xmlns=\"http://www.w3.org/1999/xhtml\">\
<head>\
<title>:: EzSpace ::</title>\
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\
\
<style type=\"text/css\">\
\
body {\
	position: relative;\
	background: #000000;\
	font: 13px Georgia;\
}\
\
.barre {\
   position: absolute;\
   color: #000000;\
   border: solid 1px #000000;\
   width: 40%;\
   text-align: right;\
}\
\
div#content {\
	position: absolute;\
	top: 10px; left: 20px; right: 20px;\
	color: #BAA;\
	background: #cccccc;\
	font: 13px Georgia;\
	padding: 20px;\
	border: solid 3px #fff;\
}\
\
.contenu {\
    position: absolute:\
	top: 10px; left: 20px; right: 20px;\
	padding: 20px;\
	color: #000000;\
}\
\
div#content h1 {\
    margin: -9px -9px 0.5em;\
    padding: 15px 0 5px;\
    text-align: right;\
    color: #667;\
    letter-spacing: 0.5em; \
    text-transform: uppercase;\
    font: bold 25px sans-serif;\
    height: 28px; vertical-align: middle;\
    white-space: nowrap;\
}\
\
.souligne {\
  left: 80px;\
  font: 13px Courier New, Courier, mono;\
  position: relative;\
  background: #efefef;\
  border-width: 1px;\
  border-style: solid;\
  width: 80%;\
  padding: 2px 2px 2px 2px;\
  text-align: left;\
  vertical-align: middle;\
}\
.event {\
  color: #6666FF;\
  font: bold 18px Georgia;\
  background: #efefef;\
  border-width: 3px;\
  border-style: solid;\
  width: 100%;\
  padding: 10px 10px 10px 2px;\
  text-align: center;\
  vertical-align: middle;\
}\
\
</style>\
</head>\
<body>\
\
<div id=\"content\">\
  <h1>EzSpace :: Projet-Espace</h1>\
  <div class=\"event\" align=\"cetner\">\
            Log du projet\
       </div>\
       <div class=\"contenu\" align=\"left\">"


class CLog 
{
    std::ofstream          my_log;
    std::string            name;
    unsigned int           ln;
public:
    std::string            l_str;


    CLog(): ln(0) 
    {
        name = "log.html";
        my_log.open(name.c_str(), std::ios::out);
        my_log.close();
        my_log.open(name.c_str(), std::ios::out|std::ios::app);
        my_log << ENTETE;
    }

    ~CLog() 
    { 
        my_log << "</div></body></html>";
        my_log.close();
    }

    void operator<< (const char *str)
    {
        my_log << "<b>( "<<++ln << " )    </b>";
        my_log << str;
        my_log << "<br />\n";
        l_str += str;
        l_str += "\n";
    }

    void printf(char *fmt, ...)
    {
        char a[1024];
  	    va_list	ap;        // on récupère la ligne apres fmt
  	    va_start(ap, fmt);
  	        vsprintf(a, fmt, ap);
  	    va_end(ap);

        my_log << "<b>( "<<++ln << " )    </b>";        
        my_log << a << "<br />\n";

        l_str += a;
        l_str += "\n";
    }

};




#endif
