IAP GITLAB

Skip to content
Snippets Groups Projects
Sink.h 669 B
Newer Older
#ifndef _include_Sink_h_
#define _include_Sink_h_

namespace corsika::logging {

  /**
     a sink for the logger must implement the two functions
ralfulrich's avatar
ralfulrich committed
     operator<<(const std::string&)
     and
     Close()
     See example: NoSink
   */
  namespace sink {
ralfulrich's avatar
ralfulrich committed
       Definition of Sink for log output.
    */
    template <typename TStream>
    class Sink {
    public:
ralfulrich's avatar
ralfulrich committed
      Sink(TStream& out)
          : fOutput(out) {}
      void operator<<(const std::string& msg) { fOutput << msg; }
      void Close() {}

    private:
ralfulrich's avatar
ralfulrich committed
      TStream& fOutput;
    typedef Sink<std::ostream> SinkStream;

ralfulrich's avatar
ralfulrich committed
  } // namespace sink
} // namespace corsika::logging