# give/4.16.9/src/Log/Commands/FlushLogsCommand.php

GiveWP – Donation Plugin and Fundraising Platform, version 4.16.9. 48 lines.

- Page: https://pluginprobe.com/plugins/give/4.16.9/code/src/Log/Commands/FlushLogsCommand.php
- Raw: https://pluginprobe.com/plugins/give/4.16.9/raw/src/Log/Commands/FlushLogsCommand.php
- Modified: 2021-11-23T23:55:18+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/give/4.16.9/code/src/Log/Commands/FlushLogsCommand.php#L10-L20`.

```php
<?php

namespace Give\Log\Commands;

use Give\Log\LogRepository;
use WP_CLI;

/**
 * Class FlushLogsCommand
 * @package Give\Log\Commands
 *
 * A WP-CLI command for flushing logs
 */
class FlushLogsCommand
{
    /**
     * @var LogRepository
     */
    private $logRepository;

    /**
     * FlushLogsCommand constructor.
     *
     * @param LogRepository $repository
     */
    public function __construct(LogRepository $repository)
    {
        $this->logRepository = $repository;
    }

    /**
     * Flush logs
     * ## EXAMPLE
     *
     *     wp give flush-logs
     */
    public function __invoke()
    {
        try {
            $this->logRepository->flushLogs();
            WP_CLI::success('Logs flushed');
        } catch (\Exception $e) {
            WP_CLI::error($e->getMessage());
        }
    }
}


```
