LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
LSSTDataManagementBasePackage
EventAppender.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 
3 /*
4  * LSST Data Management System
5  * Copyright 2008-2015 AURA/LSST.
6  *
7  * This product includes software developed by the
8  * LSST Project (http://www.lsst.org/).
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the LSST License Statement and
21  * the GNU General Public License along with this program. If not,
22  * see <https://www.lsstcorp.org/LegalNotices/>.
23  */
24 
34 #ifndef LSST_CTRL_EVENTS_EVENTAPPENDER_H
35 #define LSST_CTRL_EVENTS_EVENTAPPENDER_H
36 
37 #include <log4cxx/appenderskeleton.h>
38 #include <log4cxx/spi/loggingevent.h>
39 #include <log4cxx/helpers/object.h>
40 #include <log4cxx/helpers/pool.h>
41 #include <log4cxx/level.h>
42 #include <limits.h>
43 
46 
47 using namespace log4cxx;
48 using namespace log4cxx::helpers;
49 
50 /* this is necessary to get the C++ code to compile correctly in the lsst.ctrl.events namespace */
51 
52 #define LSST_IMPLEMENT_LOG4CXX_OBJECT(object)\
53 const Class& object::getClass() const { return getStaticClass(); }\
54 const Class& object::getStaticClass() { \
55  static Clazz##object theClass; \
56  return theClass; \
57 } \
58 const ClassRegistration& object::registerClass() { \
59  static ClassRegistration classReg(object::getStaticClass); \
60  return classReg; \
61 }\
62 namespace log4cxx { namespace classes { \
63 const ClassRegistration& object##Registration = object::registerClass(); \
64 } }
65 
66 namespace lsst {
67 namespace ctrl {
68 namespace events {
69 
75 class EventAppender : public log4cxx::AppenderSkeleton
76 {
77 public:
78 
79  /* log4cxx macro invocations required in order to expose EventAppender to the log4cxx structure */
80  DECLARE_LOG4CXX_OBJECT(EventAppender)
81 
82  BEGIN_LOG4CXX_CAST_MAP()
83  LOG4CXX_CAST_ENTRY(EventAppender)
84  LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
85  END_LOG4CXX_CAST_MAP()
86 
87  EventAppender();
88  ~EventAppender();
89 
99  virtual void setOption(const LogString& option, const LogString& value);
100 
101  /* log4cxx methods */
102 
106  virtual void activateOptions(log4cxx::helpers::Pool& p);
110  void append(const spi::LoggingEventPtr& event, log4cxx::helpers::Pool& p);
114  void close();
119  bool requiresLayout() const { return false; }
120 
121 protected:
122  lsst::ctrl::events::EventTransmitter* getTransmitter(); /* method to return currently active transmitter */
124 
125  LogString _broker; /* name of the broker */
126  LogString _topic; /* name of the topic where events are sent */
127  int _port; /* port number used by the broker */
128 
129 };
131 }}}
132 
133 #endif /*end LSST_CTRL_EVENTS_EVENTAPPENDER_H*/
defines the EventTransmitter class
lsst::ctrl::events::EventTransmitter * _transmitter
Transmit events to the event bus.
bool requiresLayout() const
this appender does not require a layout to format the text
information about the Event Broker
log4cxx appender class which sends logging messages out on the event stream
Definition: EventAppender.h:75
LOG4CXX_PTR_DEF(EventAppender)