mirror of
https://github.com/OpenNebula/one.git
synced 2025-01-08 21:17:43 +03:00
feature #1766: SysLog support selectable at build time
This commit is contained in:
parent
2f8db6ae2d
commit
562561c6ed
10
SConstruct
10
SConstruct
@ -118,8 +118,14 @@ if mysql=='yes':
|
||||
else:
|
||||
main_env.Append(mysql='no')
|
||||
|
||||
# log4cpp
|
||||
main_env.Append(LIBS=['pthread','log4cpp'])
|
||||
# SysLog
|
||||
syslog=ARGUMENTS.get('syslog', 'no')
|
||||
if syslog=='yes':
|
||||
main_env.Append(syslog='yes')
|
||||
main_env.Append(CPPFLAGS=["-DSYSLOG_LOG"])
|
||||
main_env.Append(LIBS=['pthread','log4cpp'])
|
||||
else:
|
||||
main_env.Append(syslog='no')
|
||||
|
||||
# xmlrpc
|
||||
xmlrpc_dir=ARGUMENTS.get('xmlrpc', 'none')
|
||||
|
@ -19,10 +19,13 @@
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "PoolObjectSQL.h"
|
||||
|
||||
#include "log4cpp/Priority.hh"
|
||||
#ifdef SYSLOG_LOG
|
||||
# include "log4cpp/Priority.hh"
|
||||
#endif /* SYSLOG_LOG */
|
||||
|
||||
using namespace std;
|
||||
|
||||
@ -144,6 +147,8 @@ public:
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef SYSLOG_LOG
|
||||
|
||||
/**
|
||||
* Send log messages to syslog
|
||||
*/
|
||||
@ -182,6 +187,31 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Dummy syslog class
|
||||
*/
|
||||
class SysLog : public Log
|
||||
{
|
||||
public:
|
||||
SysLog(const MessageType level,
|
||||
const string& label) {
|
||||
throw runtime_error("Aborting oned, SysLog support not compiled!");
|
||||
};
|
||||
|
||||
virtual ~SysLog() {};
|
||||
|
||||
virtual void log(
|
||||
const char * module,
|
||||
const MessageType type,
|
||||
const char * message) {};
|
||||
};
|
||||
|
||||
#endif /* SYSLOG_LOG */
|
||||
|
||||
#ifdef SYSLOG_LOG
|
||||
|
||||
/**
|
||||
* Send log messages to syslog per resource. It requires a Root Syslog
|
||||
* to be initialized before using a SysLogResource
|
||||
@ -214,4 +244,28 @@ protected:
|
||||
string obj_label;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/**
|
||||
* Dummy SysLogResource class
|
||||
*/
|
||||
class SysLogResource : public SysLog
|
||||
{
|
||||
public:
|
||||
SysLogResource(int oid,
|
||||
const PoolObjectSQL::ObjectType obj_type,
|
||||
const MessageType clevel):SysLog(clevel, "") {
|
||||
throw runtime_error("Aborting oned, SysLog support not compiled!");
|
||||
};
|
||||
|
||||
virtual ~SysLogResource(){};
|
||||
|
||||
void log(
|
||||
const char * module,
|
||||
const MessageType type,
|
||||
const char * message) {};
|
||||
};
|
||||
|
||||
#endif /* SYSLOG_LOG */
|
||||
|
||||
#endif /* _LOG_H_ */
|
||||
|
@ -20,7 +20,10 @@
|
||||
#include "Log.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <syslog.h>
|
||||
|
||||
#ifdef SYSLOG_LOG
|
||||
# include <syslog.h>
|
||||
#endif /* SYSLOG_LOG */
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
@ -25,15 +25,17 @@
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <syslog.h>
|
||||
#ifdef SYSLOG_LOG
|
||||
# include <syslog.h>
|
||||
|
||||
#include "log4cpp/Category.hh"
|
||||
#include "log4cpp/CategoryStream.hh"
|
||||
#include "log4cpp/Appender.hh"
|
||||
#include "log4cpp/SyslogAppender.hh"
|
||||
#include "log4cpp/Layout.hh"
|
||||
#include "log4cpp/PatternLayout.hh"
|
||||
#include "log4cpp/Priority.hh"
|
||||
# include "log4cpp/Category.hh"
|
||||
# include "log4cpp/CategoryStream.hh"
|
||||
# include "log4cpp/Appender.hh"
|
||||
# include "log4cpp/SyslogAppender.hh"
|
||||
# include "log4cpp/Layout.hh"
|
||||
# include "log4cpp/PatternLayout.hh"
|
||||
# include "log4cpp/Priority.hh"
|
||||
#endif /* SYSLOG_LOG */
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -158,6 +160,8 @@ void CerrLog::log(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef SYSLOG_LOG
|
||||
|
||||
const char * SysLog::CATEGORY = "ROOT";
|
||||
string SysLog::LABEL;
|
||||
|
||||
@ -313,3 +317,5 @@ void SysLogResource::log(
|
||||
<< line;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SYSLOG_LOG */
|
||||
|
Loading…
Reference in New Issue
Block a user