2 * Copyright 2004-present Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * This file contains function to help configure the logging library behavior
20 * during program start-up.
27 #include <folly/Range.h>
28 #include <folly/experimental/logging/LogLevel.h>
33 * Configure log category levels based on a configuration string.
35 * This can be used to process a logging configuration string (such as received
36 * via a command line flag) during program start-up.
39 folly::StringPiece configString = "",
40 LogLevel defaultRootLevel = LogLevel::WARNING);
43 * Initialize the logging library to write glog-style messages to stderr.
45 * This initializes the log category levels as specified (using
46 * initLogLevels()), and adds a log handler that prints messages in glog-style
49 void initLoggingGlogStyle(
50 folly::StringPiece configString = "",
51 LogLevel defaultRootLevel = LogLevel::WARNING,
52 bool asyncWrites = true);
55 * LoggingConfigError may be thrown by initLogLevels() if an error occurs
56 * parsing the configuration string.
58 class LoggingConfigError : public std::invalid_argument {
60 explicit LoggingConfigError(const std::vector<std::string>& errors);
63 std::string computeMessage(const std::vector<std::string>& errors);