/*
 * SPDX-FileCopyrightText: 2000-2002 Copyright LifeLine Networks BV (www.lifeline.nl)
 * SPDX-FileCopyrightText: 2000-2002 Copyright Bastiaan Bakker
 * SPDX-FileCopyrightText: 2004 Copyright contributors to the cppTango project
 *
 * SPDX-License-Identifier: LGPL-3.0-or-later
 */

#ifndef TANGO_COMMON_LOG4TANGO_ROLLINGFILEAPPENDER_H
#define TANGO_COMMON_LOG4TANGO_ROLLINGFILEAPPENDER_H

#include <tango/common/log4tango/FileAppender.h>
#include <tango/common/log4tango/Portability.h>

namespace log4tango
{

//-----------------------------------------------------------------------------
// class RollingFileAppender (olls over the logfile)
//-----------------------------------------------------------------------------
class RollingFileAppender : public FileAppender
{
  public:
    RollingFileAppender(const std::string &name,
                        const std::string &file_name,
                        size_t max_fs = 10 * 1024 * 1024,
                        unsigned int max_bi = 1,
                        bool append = true,
                        mode_t mode = 00644);

    virtual void set_max_backup_index(unsigned int maxBackups);

    virtual unsigned int get_max_backup_index() const;

    virtual void set_maximum_file_size(size_t max_fs);

    virtual size_t get_max_file_size() const;

    virtual void roll_over();

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

    unsigned int _max_backup_index;

    size_t _max_file_size;
};

} // namespace log4tango

#endif // TANGO_COMMON_LOG4TANGO_ROLLINGFILEAPPENDER_H
