Kea 3.3.3
legal_syslog.cc
Go to the documentation of this file.
1// Copyright (C) 2025-2026 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>
11#include <log/logger_manager.h>
12#include <log/macros.h>
15
16#include <legal_syslog.h>
17
18using namespace isc;
19using namespace isc::db;
20using namespace isc::dhcp;
21using namespace isc::log;
22using namespace isc::process;
23using namespace std;
24
25namespace isc {
26namespace legal_log {
27
29 : LegalLogMgr(parameters) {
31 // Remove default destinations as we are going to replace them.
32 info.clearDestinations();
40 info.name_ = "legal-log-";
41 info.name_ += boost::lexical_cast<std::string>(reinterpret_cast<uint64_t>(this));
42 logger_.reset(new Logger(info.name_.c_str()));
44 dest.output_ = "syslog:";
45 if (parameters.find("facility") != parameters.end()) {
46 dest.output_ += parameters.at("facility");
47 } else {
48 dest.output_ += "LOCAL0";
49 }
50 if (parameters.find("pattern") != parameters.end()) {
51 dest.pattern_ = parameters.at("pattern");
52 }
53 info.destinations_.push_back(dest);
54 CfgMgr::instance().getStagingCfg()->addLoggingInfo(info);
55}
56
57void
60
61void
64
65void
66LegalSyslog::writeln(const string& text, const string&) {
67 LOG_INFO(*logger_, LEGAL_LOG_SYSLOG)
68 .arg(text);
69}
70
71string
73 return ("syslog");
74}
75
82
83} // namespace legal_log
84} // 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:129
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