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.
18 #include <folly/Range.h>
19 #include <folly/experimental/logging/LogFormatter.h>
24 * A LogFormatter implementation that produces messages in a format similar to
25 * that produced by the Google logging library.
27 * The glog message format is:
29 * LmmDD HH:MM:SS.USECS THREAD [THREADNAME] (THREADCTX) FILE:LINE] MSG
31 * L: A 1-character code describing the log level (e.g., E, W, I, V)
34 * HH: 2-digit hour, 24-hour format
37 * USECS: 6-digit microseconds
39 * FILE: Filename (just the last component)
41 * MSG: The actual log message
43 * [THREADNAME] is the thread name, and is only included if --logthreadnames
44 * was enabled on the command line.
46 * (THREADCTX) is thread-local log context data, if it has been set. (This is
47 * a Facebook-specific modification, and is disabled unless --logthreadcontext
48 * was enabled on the command line.)
50 * Exception information and a custom log prefix may also appear after the
51 * file name and line number, before the ']' character.
53 class GlogStyleFormatter : public LogFormatter {
55 std::string formatMessage(
56 const LogMessage& message,
57 const LogCategory* handlerCategory) override;