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


log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung
autogenerated on Sun Jun 23 2019 19:10:00