mirror of https://github.com/pvnis/srsRAN_4G.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
4 years ago
|
/**
|
||
5 years ago
|
*
|
||
4 years ago
|
* \section COPYRIGHT
|
||
5 years ago
|
*
|
||
4 years ago
|
* Copyright 2013-2021 Software Radio Systems Limited
|
||
5 years ago
|
*
|
||
4 years ago
|
* By using this file, you agree to the terms and conditions set
|
||
|
* forth in the LICENSE file which can be found at the top level of
|
||
|
* the distribution.
|
||
5 years ago
|
*
|
||
|
*/
|
||
|
|
||
|
#ifndef SRSLOG_SINK_H
|
||
|
#define SRSLOG_SINK_H
|
||
|
|
||
4 years ago
|
#include "srsran/srslog/detail/support/error_string.h"
|
||
|
#include "srsran/srslog/detail/support/memory_buffer.h"
|
||
|
#include "srsran/srslog/formatter.h"
|
||
4 years ago
|
#include <cassert>
|
||
5 years ago
|
|
||
|
namespace srslog {
|
||
|
|
||
|
/// This interface provides the way to write incoming memory buffers to any kind
|
||
|
/// of backing store.
|
||
|
class sink
|
||
|
{
|
||
|
public:
|
||
4 years ago
|
explicit sink(std::unique_ptr<log_formatter> f) : formatter(std::move(f))
|
||
|
{
|
||
|
assert(formatter && "Invalid formatter");
|
||
|
}
|
||
|
|
||
5 years ago
|
virtual ~sink() = default;
|
||
|
|
||
4 years ago
|
/// Returns the formatter used by this sink.
|
||
|
log_formatter& get_formatter() { return *formatter; }
|
||
|
const log_formatter& get_formatter() const { return *formatter; }
|
||
|
|
||
5 years ago
|
/// Writes the provided memory buffer into the sink.
|
||
|
virtual detail::error_string write(detail::memory_buffer buffer) = 0;
|
||
|
|
||
|
/// Flushes any buffered contents to the backing store.
|
||
|
virtual detail::error_string flush() = 0;
|
||
4 years ago
|
|
||
|
private:
|
||
|
std::unique_ptr<log_formatter> formatter;
|
||
5 years ago
|
};
|
||
|
|
||
|
} // namespace srslog
|
||
|
|
||
|
#endif // SRSLOG_SINK_H
|