00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "PortabilityImpl.hh"
00010
00011 #ifdef LOG4CPP_HAVE_LIBIDSA
00012
00013 #include <unistd.h>
00014 #include <sys/types.h>
00015 #include <sys/stat.h>
00016 #include <fcntl.h>
00017 #include <log4cpp/IdsaAppender.hh>
00018 #include <log4cpp/FactoryParams.hh>
00019 #include <memory>
00020
00021 namespace log4cpp {
00022
00023 IdsaAppender::IdsaAppender(const std::string& name,
00024 const std::string& idsaName) :
00025 AppenderSkeleton(name),
00026 _idsaName(idsaName)
00027 {
00028 _idsaConnection=NULL;
00029 open();
00030 }
00031
00032 IdsaAppender::~IdsaAppender() {
00033 close();
00034 }
00035
00036 void IdsaAppender::open() {
00037 _idsaConnection=idsa_open((char *)_idsaName.c_str(), NULL,
00038 IDSA_F_FAILOPEN);
00039 }
00040
00041 void IdsaAppender::close() {
00042 idsa_close(_idsaConnection);
00043 _idsaConnection=NULL;
00044 }
00045
00046 void IdsaAppender::_append(const LoggingEvent& event) {
00047 IDSA_EVENT *idsaEvent;
00048
00049 idsaEvent = idsa_event(_idsaConnection);
00050
00051 if (idsaEvent){
00052
00053 idsa_name(idsaEvent,(char *)event.categoryName.c_str());
00054 idsa_scheme(idsaEvent,"log4cpp");
00055
00056 idsa_add_integer(idsaEvent, "priority", event.priority);
00057 idsa_add_string(idsaEvent, "ndc", (char *)event.ndc.c_str());
00058 idsa_add_string(idsaEvent, "message",
00059 (char*)event.message.c_str());
00060
00061 idsa_log(_idsaConnection,idsaEvent);
00062
00063 }
00064 }
00065
00066 bool IdsaAppender::reopen() {
00067 close();
00068 open();
00069 return true;
00070 }
00071
00072 bool IdsaAppender::requiresLayout() const {
00073 return false;
00074 }
00075
00076 void IdsaAppender::setLayout(Layout* layout) {
00077 return;
00078 }
00079
00080 std::auto_ptr<Appender> create_idsa_appender(const FactoryParams& params)
00081 {
00082 std::string name, idsa_name;
00083 params.get_for("idsa appender").required("name", name)("idsa_name", idsa_name);
00084
00085 return std::auto_ptr<Appender>(new IdsaAppender(name, idsa_name));
00086 }
00087 }
00088
00089 #endif // LOG4CPP_HAVE_LIBIDSA