Fawkes API  Fawkes Development Version
file.h
00001 
00002 /***************************************************************************
00003  *  file.h - Fawkes file logger
00004  *
00005  *  Created: Tue Jan 16 16:47:03 2007
00006  *  Copyright  2006-2007  Tim Niemueller [www.niemueller.de]
00007  *             2007       Daniel Beck
00008  *
00009  ****************************************************************************/
00010 
00011 /*  This program is free software; you can redistribute it and/or modify
00012  *  it under the terms of the GNU General Public License as published by
00013  *  the Free Software Foundation; either version 2 of the License, or
00014  *  (at your option) any later version. A runtime exception applies to
00015  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00016  *
00017  *  This program is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU Library General Public License for more details.
00021  *
00022  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00023  */
00024 
00025 #ifndef __UTILS_LOGGING_FILE_H_
00026 #define __UTILS_LOGGING_FILE_H_
00027 
00028 #include <logging/logger.h>
00029 #include <cstdio>
00030 #include <ctime>
00031 
00032 namespace fawkes {
00033 
00034 class Mutex;
00035 
00036 class FileLogger : public Logger
00037 {
00038  public:
00039   FileLogger(const char* filename, LogLevel min_level = LL_DEBUG);
00040   virtual ~FileLogger();
00041 
00042   virtual void log_debug(const char *component, const char *format, ...);
00043   virtual void log_info(const char *component, const char *format, ...);
00044   virtual void log_warn(const char *component, const char *format, ...);
00045   virtual void log_error(const char *component, const char *format, ...);
00046 
00047   virtual void vlog_debug(const char *component, const char *format, va_list va);
00048   virtual void vlog_info(const char *component, const char *format, va_list va);
00049   virtual void vlog_warn(const char *component, const char *format, va_list va);
00050   virtual void vlog_error(const char *component, const char *format, va_list va);
00051 
00052   virtual void log_debug(const char *component, Exception &e);
00053   virtual void log_info(const char *component, Exception &e);
00054   virtual void log_warn(const char *component, Exception &e);
00055   virtual void log_error(const char *component, Exception &e);
00056 
00057 
00058   virtual void tlog_debug(struct timeval *t, const char *component, const char *format, ...);
00059   virtual void tlog_info(struct timeval *t, const char *component, const char *format, ...);
00060   virtual void tlog_warn(struct timeval *t, const char *component, const char *format, ...);
00061   virtual void tlog_error(struct timeval *t, const char *component, const char *format, ...);
00062 
00063   virtual void tlog_debug(struct timeval *t, const char *component, Exception &e);
00064   virtual void tlog_info(struct timeval *t, const char *component, Exception &e);
00065   virtual void tlog_warn(struct timeval *t, const char *component, Exception &e);
00066   virtual void tlog_error(struct timeval *t, const char *component, Exception &e);
00067 
00068   virtual void vtlog_debug(struct timeval *t, const char *component,
00069                            const char *format, va_list va);
00070   virtual void vtlog_info(struct timeval *t, const char *component,
00071                           const char *format, va_list va);
00072   virtual void vtlog_warn(struct timeval *t, const char *component,
00073                           const char *format, va_list va);
00074   virtual void vtlog_error(struct timeval *t, const char *component,
00075                            const char *format, va_list va);
00076 
00077  private:
00078   struct ::tm *now_s;
00079 
00080   FILE        *log_file;
00081   Mutex       *mutex;
00082 };
00083 
00084 
00085 } // end namespace fawkes
00086 
00087 #endif