36 #include <sys/types.h> 41 #ifdef SNMP_PP_NAMESPACE 46 #define ERROR_LOG 0x10 47 #define WARNING_LOG 0x20 48 #define EVENT_LOG 0x30 50 #define DEBUG_LOG 0x50 53 #define LOG_CLASS_MASK 0xF0 54 #define LOG_LEVEL_MASK 0x0F 60 #define LOG_BEGIN(name,level) (void)0 61 #define LOG(item) (void)0 62 #define LOG_END (void)0 68 #define LOG_BEGIN(name,level) \ 70 if (DefaultLog::log()->log_needed(name,level)) \ 73 DefaultLog::create_log_entry(name,level) 75 #define LOG(item) *DefaultLog::log_entry() += item 78 *DefaultLog::log() += DefaultLog::log_entry(); \ 79 DefaultLog::delete_log_entry(); \ 80 DefaultLog::unlock(); \ 85 #define LOG_UNUSED(x) x 122 LogEntry(
const char *
const n,
unsigned char t) : name(n), type(t), count(0) {}
139 virtual LogEntry& operator+=(
const long l);
146 virtual LogEntry& operator+=(
const char* s);
192 virtual bool add_string(
const char* s) = 0;
201 virtual bool add_integer(
long s);
206 virtual bool add_timestamp();
217 #define MAX_LOG_SIZE 2550 // increased until debugprintf is not used! 245 output_stopped =
false;
279 bool add_string(
const char* s);
313 #ifdef WITH_LOG_PROFILES 323 virtual void set_profile(
const char *
const logprofile);
333 virtual void set_filter(
int logclass,
unsigned char filter);
340 virtual unsigned char get_filter(
int logclass)
const;
349 virtual LogEntry* create_log_entry(
const char *
const name,
unsigned char t)
const = 0;
370 virtual bool log_needed(
const char *
const,
unsigned char t)
const 371 {
return (logfilter[(t / 16) - 1] != 0xFF) && ((t &
LOG_LEVEL_MASK) <= logfilter[(t / 16) - 1]); }
384 virtual const char* now(
char* buf = 0);
395 static const char* get_current_time();
442 void set_dest(
const char* fname);
449 void set_dest(FILE* fp);
458 virtual LogEntry* create_log_entry(
const char *
const name,
unsigned char t)
const;
503 { lock();
if (instance)
delete instance; instance = logger; unlock(); }
526 static void cleanup();
553 entry = log()->create_log_entry(name, type);
613 #ifdef SNMP_PP_NAMESPACE 617 #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.