Kea 3.0.0
legal_syslog.cc
Go to the documentation of this file.
1// Copyright (C) 2025 Internet Systems Consortium, Inc. ("ISC")
2//
3// This Source Code Form is subject to the terms of the Mozilla Public
4// License, v. 2.0. If a copy of the MPL was not distributed with this
5// file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7#include <config.h>
8
9#include <dhcpsrv/cfgmgr.h>
10#include <legal_log_log.h>
11#include <legal_syslog.h>
12#include <log/logger_manager.h>
14#include <log/macros.h>
16
17using namespace isc;
18using namespace isc::db;
19using namespace isc::dhcp;
20using namespace isc::log;
21using namespace isc::process;
22using namespace std;
23
24namespace isc {
25namespace legal_log {
26
28 : LegalLogMgr(parameters) {
30 // Remove default destinations as we are going to replace them.
31 info.clearDestinations();
39 info.name_ = "legal-log-";
40 info.name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
41 logger_.reset(new Logger(info.name_.c_str()));
43 dest.output_ = "syslog:";
44 if (parameters.find("facility") != parameters.end()) {
45 dest.output_ += parameters.at("facility");
46 } else {
47 dest.output_ += "LOCAL0";
48 }
49 if (parameters.find("pattern") != parameters.end()) {
50 dest.pattern_ = parameters.at("pattern");
51 }
52 info.destinations_.push_back(dest);
53 CfgMgr::instance().getStagingCfg()->addLoggingInfo(info);
54}
55
56void
59
60void
63
64void
65LegalSyslog::writeln(const string& text, const string&) {
66 LOG_INFO(*logger_, LEGAL_LOG_SYSLOG)
67 .arg(text);
68}
69
70string
72 return ("syslog");
73}
74
81
82} // namespace legal_log
83} // namespace isc
static std::string redactedAccessString(const ParameterMap &parameters)
Redact database access string.
std::map< std::string, std::string > ParameterMap
Database configuration parameter map.
static CfgMgr & instance()
returns a single instance of Configuration Manager
Definition cfgmgr.cc:29
SrvConfigPtr getStagingCfg()
Returns a pointer to the staging configuration.
Definition cfgmgr.cc:121
LegalLogMgr(const isc::db::DatabaseConnection::ParameterMap parameters)
Constructor.
virtual std::string getType() const
Return backend type.
LegalSyslog(const isc::db::DatabaseConnection::ParameterMap &parameters)
Constructor.
virtual void writeln(const std::string &text, const std::string &addr)
Appends a string to the store with a timestamp and address.
static isc::dhcp::LegalLogMgrPtr factory(const isc::db::DatabaseConnection::ParameterMap &parameters)
Factory class method.
virtual void close()
Closes the store.
virtual void open()
Opens the store.
Logger Class.
Definition log/logger.h:142
structure that describes one logging entry
const isc::log::MessageID LEGAL_LOG_SYSLOG
const isc::log::MessageID LEGAL_LOG_SYSLOG_STORE_OPEN
#define LOG_INFO(LOGGER, MESSAGE)
Macro to conveniently test info output and log it.
Definition macros.h:20
@ info
Definition db_log.h:120
boost::shared_ptr< LegalLogMgr > LegalLogMgrPtr
Defines a smart pointer to a LegalLogMgr.
isc::log::Logger legal_log_logger("legal-log-hooks")
Legal Log Logger.
Defines the logger used by the top-level component of kea-lfc.
Defines single logging destination.
std::string output_
defines logging destination output
std::string pattern_
defines the log format pattern It dictates what additional elements are output