36 #include <sys/types.h> 42 #ifdef SNMP_PP_NAMESPACE 47 #define ERROR_LOG 0x10 48 #define WARNING_LOG 0x20 49 #define EVENT_LOG 0x30 51 #define DEBUG_LOG 0x50 54 #define LOG_CLASS_MASK 0xF0 55 #define LOG_LEVEL_MASK 0x0F 61 #define LOG_BEGIN(name,level) (void)0 62 #define LOG(item) (void)0 63 #define LOG_END (void)0 69 #define LOG_BEGIN(name,level) \ 71 if (DefaultLog::log()->log_needed(name,level)) \ 74 DefaultLog::create_log_entry(name,level) 76 #define LOG(item) *DefaultLog::log_entry() += item 79 *DefaultLog::log() += DefaultLog::log_entry(); \ 80 DefaultLog::delete_log_entry(); \ 81 DefaultLog::unlock(); \ 86 #define LOG_UNUSED(x) x 123 LogEntry(
const char *
const n,
unsigned char t) : name(n), type(t), count(0) {}
140 virtual LogEntry& operator+=(
const long l);
147 virtual LogEntry& operator+=(
const char* s);
193 virtual bool add_string(
const char* s) = 0;
202 virtual bool add_integer(
long s);
207 virtual bool add_timestamp();
218 #define MAX_LOG_SIZE 2550 // increased until debugprintf is not used! 246 output_stopped =
false;
280 bool add_string(
const char* s);
314 #ifdef WITH_LOG_PROFILES 324 virtual void set_profile(
const char *
const logprofile);
334 virtual void set_filter(
int logclass,
unsigned char filter);
341 virtual unsigned char get_filter(
int logclass)
const;
350 virtual LogEntry* create_log_entry(
const char *
const name,
unsigned char t)
const = 0;
371 virtual bool log_needed(
const char *
const,
unsigned char t)
const 372 {
return (logfilter[(t / 16) - 1] != 0xFF) && ((t &
LOG_LEVEL_MASK) <= logfilter[(t / 16) - 1]); }
385 virtual const char* now(
char* buf = 0);
396 static const char* get_current_time();
443 void set_dest(
const char* fname);
450 void set_dest(FILE* fp);
459 virtual LogEntry* create_log_entry(
const char *
const name,
unsigned char t)
const;
504 { lock();
if (instance)
delete instance; instance = logger; unlock(); }
527 static void cleanup();
554 entry = log()->create_log_entry(name, type);
614 #ifdef SNMP_PP_NAMESPACE 618 #endif // _SNMP_LOG_H_
virtual ~AgentLog()
Virtual destructor.
virtual const char * get_value() const
Get the contents of this log entry.
static void unlock()
Unlock the log singleton.
unsigned char get_level() const
Get the level of this log entry.
static const char defaultName
unsigned char get_class() const
Get the class of this log entry.
LogEntry(const char *const n, unsigned char t)
Constructor with log class and severity level.
The LogEntry class represents log entries.
The LogEntryImpl class implements a log entry using a dynamically allocated, but fixed-size buffer...
static void create_log_entry(const char *name, unsigned char type)
Create a new log entry or reuse an existing one.
static void lock()
Lock the log singleton.
static SnmpSynchronized mutex
static AgentLog * log()
Return the default logger.
virtual bool log_needed(const char *const, unsigned char t) const
Check whether a logging for the given type of LogEntry has to be done or not.
static void delete_log_entry()
Delete current log entry.
virtual ~LogEntryImpl()
Destructor.
LogEntryImpl(const char *const n, unsigned char t)
Constructor with log class and severity level.
The AgentLogImpl class is an implementation of AgentLog which writes log messages to a file...
unsigned int bytes_left()
Count the bytes left for additional values.
static AgentLog * instance
static void init(AgentLog *logger)
Initialize the default logger with the given logging implementation.
static LogEntry * log_entry()
Return the current log entry.
virtual ~LogEntry()
Virtual destructor.
unsigned char get_type() const
Get the type of this log entry.
const char * get_name() const
Get the logger name of this log entry.
The AgentLog class is an abstract base class representing a log for information that is generated dur...
The DefaultLog class has a static Log member, that is used by the AGENT++ API for logging...
virtual const char * get_value() const
Get the contents of this log entry.