// Copyright (C) 2011-2020 Internet Systems Consortium, Inc. ("ISC") // // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. #include #include #include #include #include #include namespace isc { namespace log { /// Default layout pattern for console logs const std::string OutputOption::DEFAULT_CONSOLE_PATTERN = "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i.%t] %m\n"; /// Default layout pattern for file logs const std::string OutputOption::DEFAULT_FILE_PATTERN = "%D{%Y-%m-%d %H:%M:%S.%q} %-5p [%c/%i.%t] %m\n"; /// Default layout pattern for syslog logs const std::string OutputOption::DEFAULT_SYSLOG_PATTERN = "%-5p [%c.%t] %m\n"; OutputOption::Destination getDestination(const std::string& dest_str) { if (boost::iequals(dest_str, "console")) { return OutputOption::DEST_CONSOLE; } else if (boost::iequals(dest_str, "file")) { return OutputOption::DEST_FILE; } else if (boost::iequals(dest_str, "syslog")) { return OutputOption::DEST_SYSLOG; } else { Logger logger("log"); LOG_ERROR(logger, LOG_BAD_DESTINATION).arg(dest_str); return OutputOption::DEST_CONSOLE; } } OutputOption::Stream getStream(const std::string& stream_str) { if (boost::iequals(stream_str, "stderr")) { return OutputOption::STR_STDERR; } else if (boost::iequals(stream_str, "stdout")) { return OutputOption::STR_STDOUT; } else { Logger logger("log"); LOG_ERROR(logger, LOG_BAD_STREAM).arg(stream_str); return OutputOption::STR_STDOUT; } } } // namespace log } // namespace isc