proxygen
printf.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017-present Facebook, Inc.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #pragma once
17 
18 /*
19  * C-style printf-like macros for the logging library.
20  *
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).
26  *
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.)
29  */
30 
31 #include <folly/logging/Logger.h>
32 #include <folly/logging/xlog.h>
33 
34 namespace folly {
36  FOLLY_PRINTF_FORMAT const char* format,
38 } // namespace folly
39 
43 #define FB_LOGC(logger, level, fmt, ...) \
44  FB_LOG(logger, level, ::folly::loggingFormatPrintf(fmt, ##__VA_ARGS__))
45 
50 #define XLOGC(level, fmt, ...) \
51  XLOG_IMPL( \
52  ::folly::LogLevel::level, \
53  ::folly::LogStreamProcessor::APPEND, \
54  ::folly::loggingFormatPrintf(fmt, ##__VA_ARGS__))
55 
61 #define XLOGC_IF(level, cond, fmt, ...) \
62  XLOG_IF_IMPL( \
63  ::folly::LogLevel::level, \
64  cond, \
65  ::folly::LogStreamProcessor::APPEND, \
66  ::folly::loggingFormatPrintf(fmt, ##__VA_ARGS__))
#define FOLLY_PRINTF_FORMAT
Definition: Portability.h:47
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
requires E e noexcept(noexcept(s.error(std::move(e))))
const char * string
Definition: Conv.cpp:212
std::string loggingFormatPrintf(const char *format,...) noexcept
Definition: printf.cpp:25
Formatter< false, Args... > format(StringPiece fmt, Args &&...args)
Definition: Format.h:271
#define FOLLY_PRINTF_FORMAT_ATTR(format_param, dots_param)
Definition: Portability.h:48