#include <ELadministrator.h>
Definition at line 32 of file ELadministrator.h.
mf::service::ELadministrator::ELadministrator |
( |
std::string const & |
applicationName | ) |
|
|
private |
Definition at line 104 of file ELadministrator.cc.
109 hostname_ = (gethostname(hostname, 1023) == 0) ? hostname :
"Unkonwn Host";
112 hostent* host =
nullptr;
113 host = gethostbyname(hostname);
115 if (host !=
nullptr) {
117 char* ip = inet_ntoa(*(
struct in_addr*)host->h_addr);
121 struct ifaddrs* ifAddrStruct =
nullptr;
122 struct ifaddrs* ifa =
nullptr;
123 void* tmpAddrPtr =
nullptr;
125 if (getifaddrs(&ifAddrStruct)) {
130 for (ifa = ifAddrStruct; ifa !=
nullptr; ifa = ifa->ifa_next) {
131 if (ifa->ifa_addr->sa_family == AF_INET) {
133 tmpAddrPtr = &((
struct sockaddr_in*)ifa->ifa_addr)->sin_addr;
134 char addressBuffer[INET_ADDRSTRLEN];
135 inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
137 }
else if (ifa->ifa_addr->sa_family == AF_INET6) {
139 tmpAddrPtr = &((
struct sockaddr_in6*)ifa->ifa_addr)->sin6_addr;
140 char addressBuffer[INET6_ADDRSTRLEN];
141 inet_ntop(AF_INET6, tmpAddrPtr, addressBuffer, INET6_ADDRSTRLEN);
157 pid_ =
static_cast<long>(getpid());
159 if (applicationName.empty()) {
161 std::stringstream ss;
162 ss <<
"//proc//" <<
pid_ <<
"//cmdline";
163 std::ifstream procfile{ss.str().c_str()};
167 if (procfile.is_open()) {
168 procfile >> procinfo;
172 size_t end = procinfo.find(
'\0');
173 size_t start = procinfo.find_last_of(
'/', end);
175 application_ = procinfo.substr(start + 1, end - start - 1);
std::string const & hostname() const
std::string const & mf::service::ELadministrator::application |
( |
| ) |
const |
|
inline |
Definition at line 58 of file ELadministrator.cc.
ELslProxy< ELzeroSeverityGen > constexpr ELzeroSeverity
ELseverityLevel highSeverity_
auto mf::service::ELadministrator::destinations |
( |
| ) |
const |
|
inline |
auto mf::service::ELadministrator::destinations |
( |
| ) |
|
|
inline |
void mf::service::ELadministrator::finish |
( |
| ) |
|
|
inline |
template<typename F >
void mf::service::ELadministrator::for_all_destinations |
( |
F |
f | ) |
|
|
inlineprivate |
Definition at line 116 of file ELadministrator.h.
destination_collection_t destinations_
f
Make Macro files for next generation.
bool mf::service::ELadministrator::hasDestination |
( |
std::string const & |
name | ) |
const |
std::string const & mf::service::ELadministrator::hostaddr |
( |
| ) |
const |
|
inline |
std::string const & mf::service::ELadministrator::hostname |
( |
| ) |
const |
|
inline |
void mf::service::ELadministrator::incrementSeverityCount |
( |
int const |
sev | ) |
|
|
inline |
Definition at line 83 of file ELadministrator.h.
std::array< int, ELseverityLevel::nLevels > severityCounts_
void mf::service::ELadministrator::log |
( |
ErrorObj & |
msg | ) |
|
Definition at line 19 of file ELadministrator.cc.
21 auto const severity = msg.xid().severity();
23 int const lev = severity.getLevel();
30 <<
"\nERROR LOGGED WITHOUT DESTINATION!\n" 31 <<
"Attaching destination \"cerr\" to ELadministrator by default\n\n";
void for_all_destinations(F f)
void updateMsg_(ErrorObj &msg) const
destination_collection_t destinations_
ELseverityLevel highSeverity_
std::array< int, ELseverityLevel::nLevels > severityCounts_
auto default_destinations_config()
long mf::service::ELadministrator::pid |
( |
| ) |
const |
|
inline |
void mf::service::ELadministrator::resetSeverityCount |
( |
ELseverityLevel |
sev | ) |
|
Definition at line 85 of file ELadministrator.cc.
std::array< int, ELseverityLevel::nLevels > severityCounts_
Definition at line 91 of file ELadministrator.cc.
94 for (
int k = from.getLevel();
k <= to.getLevel(); ++
k)
std::array< int, ELseverityLevel::nLevels > severityCounts_
void mf::service::ELadministrator::resetSeverityCount |
( |
| ) |
|
Definition at line 99 of file ELadministrator.cc.
ELslProxy< ELhighestSeverityGen > constexpr ELhighestSeverity
ELslProxy< ELzeroSeverityGen > constexpr ELzeroSeverity
void resetSeverityCount()
void mf::service::ELadministrator::setApplication |
( |
std::string const & |
application | ) |
|
void mf::service::ELadministrator::setHighSeverity |
( |
ELseverityLevel const |
sev | ) |
|
|
inline |
int mf::service::ELadministrator::severityCount |
( |
ELseverityLevel |
sev | ) |
const |
Definition at line 66 of file ELadministrator.cc.
std::array< int, ELseverityLevel::nLevels > severityCounts_
Definition at line 72 of file ELadministrator.cc.
75 int k = from.getLevel();
78 while (++k <= to.getLevel())
std::array< int, ELseverityLevel::nLevels > severityCounts_
void mf::service::ELadministrator::updateMsg_ |
( |
ErrorObj & |
msg | ) |
const |
|
private |
Definition at line 182 of file ELadministrator.cc.
184 auto const& xid = msg.xid();
185 if (xid.hostname().empty()) {
188 if (xid.hostaddr().empty()) {
191 if (xid.application().empty()) {
194 if (xid.pid() == 0) {
std::string const & hostname() const
std::string const & hostaddr() const
std::string const & application() const
std::string mf::service::ELadministrator::application_ {} |
|
private |
long mf::service::ELadministrator::pid_ {} |
|
private |
The documentation for this class was generated from the following files: