#ifndef _H_CLOG
#define _H_CLOG

#define LOG_MAX 10			// logs per server
#define LOG_HOUR 6			// renew the logs everyday at 6am
#define LOG_SIZE 1048576		// each log's maximum size in bytes

#define TIME_SIZE 100

class CLog;

#include "CBot.h"

class CLog {
public:
  CLog (CBot *);
  ~CLog (void);

  bool conf (c_char, c_char, bool, int);
  friend CLog &operator << (CLog &, c_char);
  friend CLog &operator << (CLog &, char);
  friend CLog &operator << (CLog &, const CString &);

  CString mail;				// mail where to send the log

private:

  void change_log (void);
  u_char get_hour (void);

  bool writing;
  CBot *b;				// bot where we belong
  fstream f;				// stream to write to
  int timemode;				// whether to write date or time
  bool flushmode;			// whether to flush after each write
  CString filename,			// current log file
          old_filename;			// old log file
  u_char hour;				// last made log's time
  char st_time[TIME_SIZE];

};

#endif
