<h3>
    {% trans "Debug Log" %}

    {% if show_options %}
        <small id="wpra-log-options-link-wrap">
            <a id="wprss-error-log-options-link" href="javascript:void(0)">
                {% trans "Options" %}
            </a>
        </small>
    {% endif %}
</h3>

{% set numLogs = logs|length %}

<div class="wpra-log">

    {% if show_options %}
        <div id="wprss-error-log-options">
            <form id="wprss-log-options-form" method="POST">
                {{ wp_nonce_field(nonce_name) }}
                <label>
                    <span>{% trans "Enable logging" %}</span>
                    <input type="checkbox" name="logging_enabled"
                           value="1" {% if config['logging/enabled'] %} checked {% endif %} />
                </label>

                <br/>

                <label>
                    <span>{% trans "Auto delete logs older than" %}</span>
                    <input type="number" name="logging_limit_days" value="{{ config['logging/limit_days'] }}" min="0"/>
                    <span>{% trans "days" %}</span>
                    <i>{% trans "(Once per day, logs older than the set amount of days are deleted)" %}</i>
                </label>

                <hr/>

                <div id="wpra-log-options-submit-wrap">
                    <button type="submit" name="wpra-log-options" class="button button-primary" value="1">
                        {% trans "Save Log Options" %}
                    </button>
                </div>
            </form>
        </div>
    {% endif %}

    {# logging disabled message #}
    {% if not config['logging/enabled'] %}
        <section class="notice notice-warning notice-inline wpra-log-disabled">
            <p>{% trans "Logging is disabled" %}</p>
        </section>
    {% endif %}

    {# log is empty message #}
    {% if numLogs == 0 %}
        <section class="notice notice-success notice-inline wpra-empty-log-notice">
            <p>{% trans "The log is empty" %}</p>
        </section>
    {% else %}

        {% if config['logging/enabled'] %}
            <p>
                <i>{{ "Showing the most recent %d log messages."|trans|format(numLogs) }}</i>
            </p>
        {% endif %}

        <p>
            <strong>{% trans "Filters:" %}</strong>

            <span class="wpra-toggle-logs" data-level="all">
                <a href="#">{% trans "All" %}</a>
            </span>
            <span class="wpra-toggle-logs wpra-selected" data-level="error">
                <a href="#">{% trans "Errors" %}</a>
            </span>
            <span class="wpra-toggle-logs wpra-selected" data-level="info">
                <a href="#">{% trans "Info" %}</a>
            </span>
            <span class="wpra-toggle-logs" data-level="notice">
                <a href="#">{% trans "Notice" %}</a>
            </span>
            <span class="wpra-toggle-logs" data-level="warning">
                <a href="#">{% trans "Warnings" %}</a>
            </span>
            <span class="wpra-toggle-logs" data-level="debug">
                <a href="#">{% trans "Debug" %}</a>
            </span>
        </p>
        <div class="wpra-log-container">
            <table>
                <tbody>
                {% for log in logs %}
                    <tr class="{{ "wpra-log-" ~ log.level }}">
                        <td class="wpra-log-date">{{ log.date }}</td>
                        <td class="wpra-log-level">{{ log.level|title }}</td>
                        <td class="wpra-log-feed">{{ log.feed.post_title }}</td>
                        <td class="wpra-log-message">{{ log.message }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        </div>

        <form id="wprss-clear-error-log-form" method="POST" class="wprss-error-log-action">
            {{ wp_nonce_field(nonce_name) }}
            <button type="submit" name="wpra-clear-log" class="button button-red" value="1">
                <i class="fa fa-trash-o"></i>
                {% trans "Clear log" %}
            </button>
        </form>

        <form id="wprss-download-error-log-form" method="POST" class="wprss-error-log-action">
            {{ wp_nonce_field(nonce_name) }}
            <button type="submit" name="wpra-download-log" class="button button-primary" value="1">
                <i class="fa fa-download"></i>
                {% trans "Download log" %}
            </button>
        </form>

    {% endif %}
</div>
