/* * 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 <condition_variable> #include <mutex> #include <thread> #include <folly/File.h> #include <folly/Range.h> #include <folly/Synchronized.h> #include <folly/logging/LogWriter.h> namespace folly { /** * An abstract LogWriter implementation that provides functionality for * asynchronous IO operations. Users can subclass this class and provide their * own IO operation implementation by overriding `performIO` method. This class * will automatically manage incoming log messages and call the method in * appropriate time. * * This class performs the log I/O in a separarate thread. * * The advantage of this class over ImmediateFileWriter is that logging I/O can * never slow down or block your normal program operation. If log messages are * generated faster than they can be written, messages will be dropped (and an * indication of how many messages were dropped will be written to the log file * when we are able to catch up a bit.) * * However, one downside is that if your program crashes, not all log messages * may have been written, so you may lose messages generated immediately before * the crash. */ class AsyncLogWriter : public LogWriter { … }; } // namespace folly