38 #include <log4cxx/helpers/stringhelper.h>
39 #include <log4cxx/helpers/pool.h>
40 #include <log4cxx/spi/location/locationinfo.h>
41 #include <log4cxx/helpers/loglog.h>
49 namespace pexExceptions = lsst::pex::exceptions;
51 using namespace log4cxx;
52 using namespace log4cxx::helpers;
54 namespace ctrlEvents = lsst::ctrl::events;
70 EventAppender::~EventAppender() {
71 if (_transmitter != NULL)
76 void EventAppender::setOption(
const LogString& option,
const LogString& value) {
77 if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR(
"BROKER"), LOG4CXX_STR(
"broker"))) {
79 }
else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR(
"PORT"), LOG4CXX_STR(
"port"))) {
80 _port = atoi(value.c_str());
81 }
else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR(
"TOPIC"), LOG4CXX_STR(
"topic"))) {
84 AppenderSkeleton::setOption(option, value);
88 void EventAppender::activateOptions(Pool&)
90 if (_broker.empty()) {
91 LogLog::error((LogString) LOG4CXX_STR(
"Appender requires broker option to be specified"));
96 }
catch (pexExceptions::RuntimeError& rte) {
97 std::ostringstream msg;
98 msg <<
"Couldn't reach broker " << _broker <<
" at port " << _port;
106 if (_transmitter == NULL) {
109 }
catch (Exception& e) {
116 void EventAppender::append(
const spi::LoggingEventPtr& event, helpers::Pool& p) {
119 psp->set(
"logger", event->getLoggerName());
120 psp->set(
"message", event->getMessage());
121 psp->set(
"timestamp", event->getTimeStamp());
122 psp->set(
"threadname", event->getThreadName());
123 psp->set(
"level", event->getLevel()->toInt());
125 spi::LocationInfo location =
event->getLocationInformation();
128 loc->set(
"filename", location.getFileName());
129 loc->set(
"classname", location.getClassName());
130 loc->set(
"methodname", location.getMethodName());
131 loc->set(
"linenumber", location.getLineNumber());
133 psp->set(
"location", loc);
139 if (_transmitter == NULL)
144 }
catch (Exception& e) {
145 LogLog::error((LogString) LOG4CXX_STR(
"event transmitter failed"));
151 void EventAppender::close() {
static const std::string LOGGING_TOPIC
defines the EventAppender class
boost::shared_ptr< PropertySet > Ptr
#define LSST_IMPLEMENT_LOG4CXX_OBJECT(object)
Transmit events to the event bus.
static const int DEFAULTHOSTPORT
void publishEvent(Event &event)
Publish an Event to this object's topic.
information about the Event Broker
Representation of an LSST Event.
Class for storing generic metadata.
log4cxx appender class which sends logging messages out on the event stream
defines the EventSystem class
Include files required for standard LSST Exception handling.