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 * C-style printf-like macros for the logging library.
21 * These are defined in their own separate header file to discourage their use
22 * in new code. These macros make it somewhat easier to convert existing code
23 * using printf()-like statements to the logging library. However, new code
24 * should generally prefer to use one of the other macro forms instead
25 * (simple argument concatenation, folly::format based, or iostream-like).
27 * These use a "C" suffix to the macro name since these use C-style format
28 * syntax. (The "F" suffix is used for folly:format()-style.)
31 #include <folly/experimental/logging/Logger.h>
32 #include <folly/experimental/logging/xlog.h>
35 std::string loggingFormatPrintf(
36 FOLLY_PRINTF_FORMAT const char* format,
37 ...) noexcept FOLLY_PRINTF_FORMAT_ATTR(1, 2);
41 * Log a message to the specified logger using a printf-style format string.
43 #define FB_LOGC(logger, level, fmt, ...) \
46 ::folly::LogLevel::level, \
47 ::folly::LogStreamProcessor::APPEND, \
48 ::folly::loggingFormatPrintf(fmt, ##__VA_ARGS__))
51 * Log a message to the file's default log category using a printf-style format
54 #define XLOGC(level, fmt, ...) \
56 ::folly::LogLevel::level, \
57 ::folly::LogStreamProcessor::APPEND, \
58 ::folly::loggingFormatPrintf(fmt, ##__VA_ARGS__))