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"))) {
83 }
else if (StringHelper::equalsIgnoreCase(option, LOG4CXX_STR(
"RUNID"), LOG4CXX_STR(
"runid"))) {
86 AppenderSkeleton::setOption(option, value);
90 void EventAppender::activateOptions(Pool&)
92 if (_broker.empty()) {
93 LogLog::error((LogString) LOG4CXX_STR(
"Appender requires broker option to be specified"));
98 }
catch (pexExceptions::RuntimeError& rte) {
99 std::ostringstream msg;
100 msg <<
"Couldn't reach broker " << _broker <<
" at port " << _port;
108 if (_transmitter == NULL) {
111 }
catch (Exception& e) {
118 void EventAppender::append(
const spi::LoggingEventPtr& event, helpers::Pool& p) {
121 psp->set(
"logger", event->getLoggerName());
122 psp->set(
"message", event->getMessage());
123 psp->set(
"timestamp", event->getTimeStamp());
124 psp->set(
"threadname", event->getThreadName());
125 psp->set(
"level", event->getLevel()->toInt());
127 spi::LocationInfo location =
event->getLocationInformation();
130 loc->set(
"filename", location.getFileName());
131 loc->set(
"classname", location.getClassName());
132 loc->set(
"methodname", location.getMethodName());
133 loc->set(
"linenumber", location.getLineNumber());
135 psp->set(
"location", loc);
138 if (_runid.empty()) {
146 if (_transmitter == NULL)
151 }
catch (Exception& e) {
152 LogLog::error((LogString) LOG4CXX_STR(
"event transmitter failed"));
158 void EventAppender::close() {
static const std::string LOGGING_TOPIC
defines the EventAppender class
Include files required for standard LSST Exception handling.
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