1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
/*
* IdsaAppender.cpp
*
* Copyright 2000, Marc Welz
*
* See the COPYING file for the terms of usage and distribution.
*/
#include "log4cpp/Portability.hh"
#ifdef LOG4CPP_HAVE_LIBIDSA
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "log4cpp/IdsaAppender.hh"
namespace log4cpp {
IdsaAppender::IdsaAppender(const std::string& name,
const std::string& idsaName) :
AppenderSkeleton(name),
_idsaName(idsaName)
{
_idsaConnection=NULL;
open();
}
IdsaAppender::~IdsaAppender() {
close();
}
void IdsaAppender::open() {
_idsaConnection=idsa_open((char *)_idsaName.c_str(), NULL,
IDSA_F_FAILOPEN);
}
void IdsaAppender::close() {
idsa_close(_idsaConnection);
_idsaConnection=NULL;
}
void IdsaAppender::_append(const LoggingEvent& event) {
IDSA_EVENT *idsaEvent;
idsaEvent = idsa_event(_idsaConnection);
if (idsaEvent){
idsa_name(idsaEvent,(char *)event.categoryName.c_str());
idsa_scheme(idsaEvent,"log4cpp");
idsa_add_integer(idsaEvent, "priority", event.priority);
idsa_add_string(idsaEvent, "ndc", (char *)event.ndc.c_str());
idsa_add_string(idsaEvent, "message",
(char*)event.message.c_str());
idsa_log(_idsaConnection,idsaEvent);
// idsa_log does its own deallocation */
}
}
bool IdsaAppender::reopen() {
close();
open();
return true;
}
bool IdsaAppender::requiresLayout() const {
return false;
}
void IdsaAppender::setLayout(Layout* layout) {
return;
}
}
#endif // LOG4CPP_HAVE_LIBIDSA
|