"Fossies" - the Fresh Open Source Software Archive

Member "hermes-1.9/src/FileLogger.h" (29 Jun 2014, 1585 Bytes) of package /linux/privat/hermes-1.9.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "FileLogger.h" see the Fossies "Dox" file reference documentation.

    1 /**
    2  * hermes antispam proxy
    3  * Copyright (C) 2006, 2007 Juan José Gutiérrez de Quevedo <juanjo@gutierrezdequevedo.com>
    4  *
    5  * This program is free software; you can redistribute it and/or modify
    6  * it under the terms of the GNU General Public License as published by
    7  * the Free Software Foundation; version 2 of the License
    8  *
    9  * This program is distributed in the hope that it will be useful,
   10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12  * GNU General Public License for more details.
   13  *
   14  * You should have received a copy of the GNU General Public License along
   15  * with this program; if not, write to the Free Software Foundation, Inc.,
   16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   17  *
   18  * @author Juan José Gutiérrez de Quevedo <juanjo@gutierrezdequevedo.com>
   19  */
   20 #ifndef FILELOGGER_H
   21 #define FILELOGGER_H
   22 
   23 #include "config.h"
   24 #include <stdio.h>
   25 #include <pthread.h>
   26 #include <string>
   27 #include <list>
   28 
   29 #include "Logger.h"
   30 #include "Configfile.h"
   31 
   32 using namespace std;
   33 
   34 /**
   35  * this class implements a logger that writes to a file
   36  *
   37  * @see Logger
   38  */
   39 class FileLogger: public Logger
   40 {
   41   unsigned char linecount;
   42   time_t last_rotation;
   43   private:
   44     FILE *f;
   45     pthread_mutex_t mutex;
   46     list<string> tmpstrings;
   47     void openFile(string);
   48     void closeFile();
   49     void syncBufferToDisk();
   50     void rotateLog();
   51     string getProcessedRotateFilename();
   52   public:
   53     FileLogger();
   54     ~FileLogger();
   55     void addMessage(string,int,int,string);
   56 };
   57 
   58 #endif //FILELOGGER_H