Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

Logger.h

00001 /* hey emacs! -*- Mode: C++; c-file-style: "stroustrup"; indent-tabs-mode: nil -*- */
00002 /*
00003  * Logger.h
00004  *   Header file for the Logger class
00005  *
00006  * $Id: Logger.h,v 1.7 2000/12/27 16:59:27 rex Exp $
00007  *
00008  * Copyright (c) 2000 Remi Lefebvre <remi@debian.org>
00009  *                and Luca Filipozzi <lfilipoz@debian.org>
00010  *
00011  * DDT comes with ABSOLUTELY NO WARRANTY and is licenced under the
00012  * GNU General Public License (version 2 or later). This license
00013  * can be retrieved from http://www.gnu.org/copyleft/gnu.html.
00014  *
00015  */
00016 
00017 #ifndef LOGGER_H
00018 #define LOGGER_H
00019 
00020 #ifdef HAVE_CONFIG_H
00021 #include "config.h"
00022 #endif
00023 
00024 #include <stdio.h>
00025 #include <syslog.h>
00026 
00032 class Logger
00033 {
00034   public:
00042     /*
00043     Logger (char* ident,        // identifier, usually program name
00044             int priority,       // syslog priority
00045             int facility,       // syslog facility, use -1 to disable
00046             char* fileName);    // file to log to, use "" to disable
00047      */
00048 
00050     static Logger* Instance();
00051 
00053     virtual ~Logger();
00054 
00056     int openSyslog(int facility, int priority);
00058     void closeSyslog();
00059 
00061     int openFilelog(char* fileName, int priority);
00063     void closeFilelog();
00064 
00066     int setSyslogPriority(int priority);
00067 
00069     int setFilelogPriority(int priority);
00070 
00072     int setIdent(char* ident);
00073 
00075     //void setPriority(int priority);
00076 
00077     void debug(const char* fmt, ...);
00078     void info(const char* fmt, ...);
00079     void notice(const char* fmt, ...);
00080     void warning(const char* fmt, ...);
00081     void error(const char* fmt, ...);
00082     void crit(const char* fmt, ...);
00083 
00084   protected:
00086     Logger(); /* hide the default constructor */
00087 
00088   private:
00089     //void log(int priority, const char *fmt, ...);
00090     void log(int priority, const char *string);
00091 
00092     char*           ident_;
00093 
00094     bool            isSyslogEnabled_;
00095     bool            isFilelogEnabled_;
00096     int             syslogPriority_;
00097     int             filelogPriority_;
00098 
00099     FILE*           file_;
00100 
00101     static Logger*  instance_;
00102 };
00103 
00104 #endif

Generated on Tue Sep 13 01:32:47 2005 for DDT Project by  doxygen 1.4.4