logfile.h

Go to the documentation of this file.
00001 /*
00002 #########################################################################
00003 #
00004 #  This file is part of trustyRC.
00005 #
00006 #  trustyRC, fully modular IRC robot 
00007 #  Copyright (C) 2006-2008 Nicoleau Fabien 
00008 #
00009 #  trustyRC is free software: you can redistribute it and/or modify
00010 #  it under the terms of the GNU General Public License as published by
00011 #  the Free Software Foundation, either version 3 of the License, or
00012 #  (at your option) any later version.
00013 #
00014 #  trustyRC is distributed in the hope that it will be useful,
00015 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 #  GNU General Public License for more details.
00018 #
00019 #  You should have received a copy of the GNU General Public License
00020 #  along with trustyRC.  If not, see <http://www.gnu.org/licenses/>.
00021 #
00022 #########################################################################
00023 */
00024 
00029 #ifndef LOGFILE_H
00030 #define LOGFILE_H
00031 
00032 #include <sys/stat.h>
00033 #include <strings.h>
00034 #include <string>
00035 #include <fstream>
00036 #include <iostream>
00037 #include <map>
00038 using namespace std;
00039 
00041 typedef enum {NOTUSED,NOTHING,ERROR,WARNING,INFO} log_level;
00042 
00050 class LogFile {
00051    public :
00053       LogFile(string,bool,bool,string,string);
00055       ~LogFile();
00057       bool open();
00059       void close();
00061       void reopen();
00063       bool log(string line,log_level ll=NOTUSED);
00065       void setPeriodFormat(string);
00067       string getPeriodFormat();
00069       void setVerbose(bool);
00071       bool getVerbose();
00073       void setKeepFiles(bool);
00075       bool getKeepFiles();
00077       log_level getLogLevel();
00079       void setLogLevel(log_level);
00081       void setLogLevel(string);
00082    private :
00084       ofstream* stream;
00086       log_level level;
00088       string baseFileName;
00090       string period;
00092       string periodFormat;
00094       string systemPeriod();
00096       bool keepFiles;
00098       bool verbose;
00100       void beginLog();
00102       void endLog();
00104       bool checkFile();
00106       string getLevelTag(log_level);
00108       log_level strToLogLevel(string);
00109 };
00110 
00111 #endif

Generated on Sun Aug 16 15:28:27 2009 for trustyRC by  doxygen 1.5.8