proxygen
StandardLogHandler.cpp
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  */
17 
21 
22 namespace folly {
23 
26  std::shared_ptr<LogFormatter> formatter,
27  std::shared_ptr<LogWriter> writer,
28  LogLevel syncLevel)
29  : syncLevel_(syncLevel),
30  formatter_{std::move(formatter)},
31  writer_{std::move(writer)},
32  config_{config} {}
33 
35 
37  const LogMessage& message,
38  const LogCategory* handlerCategory) {
39  if (message.getLevel() < getLevel()) {
40  return;
41  }
42  writer_->writeMessage(formatter_->formatMessage(message, handlerCategory));
43  if (message.getLevel() >= syncLevel_.load(std::memory_order_relaxed)) {
44  flush();
45  }
46 }
47 
49  writer_->flush();
50 }
51 
53  return config_;
54 }
55 
56 } // namespace folly
LogHandlerConfig getConfig() const override
Definition: test.c:42
void handleMessage(const LogMessage &message, const LogCategory *handlerCategory) override
const std::shared_ptr< LogWriter > writer_
const LogHandlerConfig config_
std::atomic< LogLevel > syncLevel_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
const std::shared_ptr< LogFormatter > formatter_
StandardLogHandler(LogHandlerConfig config, std::shared_ptr< LogFormatter > formatter, std::shared_ptr< LogWriter > writer, LogLevel syncLevel=LogLevel::MAX_LEVEL)
AHArrayT::Config config
LogLevel getLevel() const
Definition: LogMessage.h:80
LogLevel
Definition: LogLevel.h:38