/*
 * SPDX-FileCopyrightText: 2004 Copyright contributors to the cppTango project
 *
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#ifndef TANGO_SERVER_TANGOAPPENDER_H
#define TANGO_SERVER_TANGOAPPENDER_H

#include <tango/common/log4tango/Appender.h>
#include <tango/common/tango_const.h>

#include <string>

namespace Tango
{
class DeviceProxy;

class TangoAppender : public log4tango::Appender
{
  public:
    /**
     *
     **/
    TangoAppender(const std::string &src_name,
                  const std::string &name,
                  const std::string &dev_name,
                  bool open_connection = true);
    /**
     *
     **/
    ~TangoAppender() override;

    /**
     *
     **/
    bool requires_layout() const override;

    /**
     *
     **/
    void set_layout(log4tango::Layout *layout) override;

    /**
     *
     **/
    void close() override;

    /**
     *
     **/
    bool reopen() override;

    /**
     *
     **/
    bool is_valid() const override;

  protected:
    /**
     *
     **/
    int _append(const log4tango::LoggingEvent &event) override;

  private:
    /**
     *
     **/
    const std::string _dev_name;

    /**
     *
     **/
    const std::string _src_name;

    /**
     *
     **/
    DeviceProxy *_dev_proxy{nullptr};
    DevULong _req_ctr;
};

} // namespace Tango

#endif // TANGO_SERVER_TANGOAPPENDER_H
