Seastar
High performance C++ framework for concurrent servers
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
log-cli.hh
1/*
2 * This file is open source software, licensed to you under the terms
3 * of the Apache License, Version 2.0 (the "License"). See the NOTICE file
4 * distributed with this work for additional information regarding copyright
5 * ownership. You may not use this file except in compliance with the License.
6 *
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 */
18/*
19 * Copyright (C) 2017 ScyllaDB
20 */
21
22#pragma once
23
24#ifndef SEASTAR_MODULE
25#include <boost/program_options.hpp>
26
27#include <algorithm>
28#include <unordered_map>
29#endif
30
31#include <seastar/util/log.hh>
32#include <seastar/util/program-options.hh>
33
34#include <seastar/core/sstring.hh>
35
36
39namespace seastar {
40
44namespace log_cli {
45
49boost::program_options::options_description get_options_description();
50
51using log_level_map = std::unordered_map<sstring, log_level>;
52
86
94};
95
99void print_available_loggers(std::ostream& os);
100
106
108void parse_map_associations(const std::string& v, std::function<void(std::string, std::string)> consume_key_value);
110
111//
112// \brief Parse associations from loggers to log-levels and write the resulting pairs to the output iterator.
113//
114// \throws \c std::runtime_error for an invalid log-level.
115//
116template <class OutputIter>
117void parse_logger_levels(const program_options::string_map& levels, OutputIter out) {
118 std::for_each(levels.begin(), levels.end(), [&out](auto&& pair) {
119 *out++ = std::make_pair(pair.first, parse_log_level(pair.second));
120 });
121}
122
125//
126logging_settings extract_settings(const boost::program_options::variables_map&);
127
131logging_settings extract_settings(const options&);
132
133}
134
135}
136
Definition: program-options.hh:293
Wrapper for command-line options with arbitrary string associations.
Definition: program-options.hh:74
log_level
log level used with
Definition: log.hh:55
log_level parse_log_level(const sstring &)
Parse a log-level ({error, warn, info, debug, trace}) string, throwing std::runtime_error for an inva...
logging_settings extract_settings(const boost::program_options::variables_map &)
Extract CLI options into a logging configuration.
boost::program_options::options_description get_options_description()
Options for controlling logging at run-time.
void print_available_loggers(std::ostream &os)
Print a human-friendly list of the available loggers.
Seastar API namespace.
Definition: abort_on_ebadf.hh:26
Logging configuration.
Definition: log-cli.hh:54
program_options::value< bool > log_to_stdout
Send log output to output stream.
Definition: log-cli.hh:76
program_options::value< seastar::logger_ostream_type > logger_ostream_type
Definition: log-cli.hh:81
program_options::value< log_level_map > logger_log_level
Map of logger name to log level.
Definition: log-cli.hh:66
program_options::value< bool > log_with_color
Definition: log-cli.hh:90
program_options::value< logger_timestamp_style > logger_stdout_timestamps
Definition: log-cli.hh:71
program_options::value< log_level > default_log_level
Default log level for log messages.
Definition: log-cli.hh:60
program_options::value< bool > log_to_syslog
Definition: log-cli.hh:85