00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __UTILS_LOGGING_LOGGER_H_
00025 #define __UTILS_LOGGING_LOGGER_H_
00026
00027 #include <core/exception.h>
00028 #include <cstdarg>
00029 #include <sys/time.h>
00030
00031 namespace fawkes {
00032
00033
00034 class Logger
00035 {
00036 public:
00037
00038
00039
00040
00041
00042
00043
00044
00045 typedef enum {
00046 LL_DEBUG = 0,
00047 LL_INFO = 1,
00048 LL_WARN = 2,
00049
00050
00051 LL_ERROR = 4,
00052
00053
00054 LL_NONE = 8
00055 } LogLevel;
00056
00057 Logger(LogLevel log_level = LL_DEBUG);
00058 virtual ~Logger();
00059
00060 virtual void set_loglevel(LogLevel level);
00061 virtual LogLevel loglevel();
00062
00063 virtual void log(LogLevel level,
00064 const char *component, const char *format, ...);
00065 virtual void log_debug(const char *component, const char *format, ...) = 0;
00066 virtual void log_info(const char *component, const char *format, ...) = 0;
00067 virtual void log_warn(const char *component, const char *format, ...) = 0;
00068 virtual void log_error(const char *component, const char *format, ...) = 0;
00069
00070
00071 virtual void log(LogLevel level, const char *component, Exception &e);
00072 virtual void log_debug(const char *component, Exception &e) = 0;
00073 virtual void log_info(const char *component, Exception &e) = 0;
00074 virtual void log_warn(const char *component, Exception &e) = 0;
00075 virtual void log_error(const char *component, Exception &e) = 0;
00076
00077 virtual void vlog(LogLevel level, const char *component,
00078 const char *format, va_list va);
00079 virtual void vlog_debug(const char *component,
00080 const char *format, va_list va) = 0;
00081 virtual void vlog_info(const char *component,
00082 const char *format, va_list va) = 0;
00083 virtual void vlog_warn(const char *component,
00084 const char *format, va_list va) = 0;
00085 virtual void vlog_error(const char *component,
00086 const char *format, va_list va) = 0;
00087
00088
00089 virtual void tlog(LogLevel level, struct timeval *t,
00090 const char *component, const char *format, ...);
00091 virtual void tlog_debug(struct timeval *t, const char *component,
00092 const char *format, ...) = 0;
00093 virtual void tlog_info(struct timeval *t, const char *component,
00094 const char *format, ...) = 0;
00095 virtual void tlog_warn(struct timeval *t, const char *component,
00096 const char *format, ...) = 0;
00097 virtual void tlog_error(struct timeval *t, const char *component,
00098 const char *format, ...) = 0;
00099
00100 virtual void tlog(LogLevel level, struct timeval *t, const char *component,
00101 Exception &e);
00102 virtual void tlog_debug(struct timeval *t, const char *component,
00103 Exception &e) = 0;
00104 virtual void tlog_info(struct timeval *t, const char *component,
00105 Exception &e) = 0;
00106 virtual void tlog_warn(struct timeval *t, const char *component,
00107 Exception &e) = 0;
00108 virtual void tlog_error(struct timeval *t, const char *component,
00109 Exception &e) = 0;
00110
00111 virtual void vtlog(LogLevel level, struct timeval *t, const char *component,
00112 const char *format, va_list va);
00113 virtual void vtlog_debug(struct timeval *t, const char *component,
00114 const char *format, va_list va) = 0;
00115 virtual void vtlog_info(struct timeval *t, const char *component,
00116 const char *format, va_list va) = 0;
00117 virtual void vtlog_warn(struct timeval *t, const char *component,
00118 const char *format, va_list va) = 0;
00119 virtual void vtlog_error(struct timeval *t, const char *component,
00120 const char *format, va_list va) = 0;
00121
00122
00123 protected:
00124
00125
00126
00127
00128 LogLevel log_level;
00129 };
00130
00131
00132 }
00133
00134 #endif