Kea: output_option.cc Source File

| Kea 3.2.0-git

output_option.cc
Go to the documentation of this file.
1// Copyright (C) 2011-2020 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 <string>
10
11#include <boost/algorithm/string.hpp>
12
13#include <log/log_messages.h>
14#include <log/macros.h>
15#include <log/output_option.h>
16
17namespace isc {
18namespace log {
19
21const std::string OutputOption::DEFAULT_CONSOLE_PATTERN = "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i.%t] %m\n";
22
24const std::string OutputOption::DEFAULT_FILE_PATTERN = "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i.%t] %m\n";
25
27const std::string OutputOption::DEFAULT_SYSLOG_PATTERN = "%-5p [%c.%t] %m\n";
28
29 OutputOption::Destination
30getDestination(const std::string& dest_str) {
31 if (boost::iequals(dest_str, "console")) {
32 return OutputOption::DEST_CONSOLE;
33 } else if (boost::iequals(dest_str, "file")) {
34 return OutputOption::DEST_FILE;
35 } else if (boost::iequals(dest_str, "syslog")) {
36 return OutputOption::DEST_SYSLOG;
37 } else {
38 Logger logger("log");
39 LOG_ERROR(logger, LOG_BAD_DESTINATION).arg(dest_str);
40 return OutputOption::DEST_CONSOLE;
41 }
42}
43
44 OutputOption::Stream
45getStream(const std::string& stream_str) {
46 if (boost::iequals(stream_str, "stderr")) {
47 return OutputOption::STR_STDERR;
48 } else if (boost::iequals(stream_str, "stdout")) {
49 return OutputOption::STR_STDOUT;
50 } else {
51 Logger logger("log");
52 LOG_ERROR(logger, LOG_BAD_STREAM).arg(stream_str);
53 return OutputOption::STR_STDOUT;
54 }
55}
56
57} // namespace log
58} // namespace isc
isc::log::Logger
Logger Class.
Definition log/logger.h:142
log_messages.h
macros.h
LOG_ERROR
#define LOG_ERROR(LOGGER, MESSAGE)
Macro to conveniently test error output and log it.
Definition macros.h:32
isc::log
Definition buffer_appender_impl.cc:17
isc::log::getDestination
OutputOption::Destination getDestination(const std::string &dest_str)
Definition output_option.cc:30
isc::log::LOG_BAD_DESTINATION
const isc::log::MessageID LOG_BAD_DESTINATION
Definition log_messages.h:11
isc::log::getStream
OutputOption::Stream getStream(const std::string &stream_str)
Definition output_option.cc:45
isc::log::LOG_BAD_STREAM
const isc::log::MessageID LOG_BAD_STREAM
Definition log_messages.h:13
isc
Defines the logger used by the top-level component of kea-lfc.
Definition check_exists_add.cc:18
output_option.h
isc::log::OutputOption::Stream
Stream
If console, stream on which messages are output.
Definition output_option.h:55
isc::log::OutputOption::STR_STDOUT
@ STR_STDOUT
Definition output_option.h:56
isc::log::OutputOption::STR_STDERR
@ STR_STDERR
Definition output_option.h:57
isc::log::OutputOption::Destination
Destination
Destinations.
Definition output_option.h:48
isc::log::OutputOption::DEST_CONSOLE
@ DEST_CONSOLE
Definition output_option.h:49
isc::log::OutputOption::DEST_SYSLOG
@ DEST_SYSLOG
Definition output_option.h:51
isc::log::OutputOption::DEST_FILE
@ DEST_FILE
Definition output_option.h:50
isc::log::OutputOption::DEFAULT_FILE_PATTERN
static const std::string DEFAULT_FILE_PATTERN
Default layout pattern for file logs.
Definition output_option.h:42
isc::log::OutputOption::DEFAULT_SYSLOG_PATTERN
static const std::string DEFAULT_SYSLOG_PATTERN
Default layout pattern for syslog logs.
Definition output_option.h:44
isc::log::OutputOption::DEFAULT_CONSOLE_PATTERN
static const std::string DEFAULT_CONSOLE_PATTERN
Default layout pattern for console logs.
Definition output_option.h:40