/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #pragma once #include <memory> #include <string> #include <unordered_map> #include <vector> #include <folly/Conv.h> #include <folly/CppAttributes.h> #include <folly/Range.h> #include <folly/ScopeGuard.h> #include <folly/Synchronized.h> #include <folly/detail/StaticSingletonManager.h> #include <folly/logging/LogName.h> namespace folly { class LogCategory; class LogConfig; class LogHandler; class LogHandlerFactory; enum class LogLevel : uint32_t; /** * LoggerDB stores the set of LogCategory objects. */ class LoggerDB { … }; /** * initializeLoggerDB() will be called to configure the main LoggerDB singleton * the first time that LoggerDB::get() is called. * * This function can be used apply basic default settings to the LoggerDB, * including default log level and log handler settings. * * A default implementation is provided as a weak symbol, so it can be * overridden on a per-program basis if you want to customize the initial * LoggerDB settings for your program. * * However, note that this function may be invoked before main() starts (if * other code that runs before main uses the logging library). Therefore you * should be careful about what code runs here. For instance, you probably * should not create LogHandler objects that spawn new threads. It is * generally a good idea to defer more complicated setup until after main() * starts. * * In most situations it is normally better to override getBaseLoggingConfig() * from logging/Init.h rather than overriding initializeLoggerDB(). You only * need to override initializeLoggerDB() if you want to change the settings * that are used for messages that get logged before initLogging() is called. * * The default implementation configures the root log category to write all * warning and higher-level log messages to stderr, using a format similar to * that used by GLOG. */ void initializeLoggerDB(LoggerDB& db); FOLLY_ALWAYS_INLINE LoggerDB& LoggerDB::get() { … } } // namespace folly