37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
/** @file PrettySinkFactory.hpp
|
|
*
|
|
* @author Roland Conybeare, Sep 2026
|
|
**/
|
|
|
|
#pragma once
|
|
|
|
#include <xo/ppsink/PpSinkFactory.hpp>
|
|
#include "xo/indentlog2/print/PpConfig.hpp"
|
|
|
|
namespace xo::pp {
|
|
/** @brief factory that creates pretty-printing sinks for logging.
|
|
*
|
|
* Sinks created by this factory forward to clog's streambuf.
|
|
**/
|
|
class PrettySinkFactory : public PpSinkFactory {
|
|
public:
|
|
explicit PrettySinkFactory(const PpConfig & x) : pp_config_{x} {}
|
|
|
|
const PpConfig & pp_config() const { return pp_config_; }
|
|
|
|
virtual bool is_flat() const override { return false; }
|
|
/** Create pretty-printing instance.
|
|
*
|
|
* @p c controls where to get PpStyle:
|
|
* @c ColorSelect::k_plain always uses @c PpStyle::plain()
|
|
* @c ColorSelect::k_colored falls through to @c pp_config_.style_
|
|
**/
|
|
virtual std::unique_ptr<PpSink> create(ColorSelect c, SinkOutput d) override;
|
|
|
|
private:
|
|
/** pretty-printing configuration **/
|
|
PpConfig pp_config_;
|
|
};
|
|
} /*namespace xo::pp*/
|
|
|
|
/* end PrettySinkFactory.hpp */
|