erdaldemirci/laravel-geoip-log-cleaner

Simple laravel package for clearing GeoIP logs.

1.0.1 2019-09-19 20:43 UTC

This package is auto-updated.

Last update: 2024-11-20 08:16:43 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Documentation

Installation

You can install this package through Composer.

  • First, edit your project's composer.json file to require erdaldemirci/laravel-geoip-log-cleaner:
"require": {
    // other require packages
    "laravel-geoip-log-cleaner": "1.*"
},
  • Next, run the composer update command in your command line interface:
$ composer update

Note: Instead of performing the above two steps, you can perform faster with the command line $ composer require erdaldemirci/laravel-geoip-log-cleaner:1.*.

  • Add following code to app\Console\Kernel.php.
protected $commands = [
    // other kernel commands
    \ErdalDemirci\GeoIPLogCleaner\Command\LogClearCommand::class,
];

Usage

Working with facade

Laravel Log Cleaner has a facade with name is ErdalDemirci\GeoIPLogCleaner\Facades\Cleaner. You can do any operation through this facade. For example:

<?php

namespace YourNamespace;

// your code

use ErdalDemirci\GeoIPLogCleaner\Facades\Cleaner;

class YourClass
{
    public function yourMethod()
    {
        Cleaner::doSomething();
    }
}

Method chaining

Some functions of loading, writing, backing up, restoring are implementation and usage of method chaining. So these functions can be called to chained together in a single statement. Examples:

$cleaner = Cleaner::rotate(14);

if ($cleaner->clear()) {
    echo 'GeoIP Log files older than 14 days in default folder were cleared successfully.';
} else {
    echo 'GeoIP Log files older than 14 days in default folder were cleared with errors.';
}

if ($cleaner->dir('path_to_logs')->clear()) {
    echo 'GeoIP Log files older than 14 days in `path_to_logs` folder were cleared successfully.';
} else {
    echo 'GeoIP Log files older than 14 days in `path_to_logs` folder were cleared with errors.';
}
if (Cleaner::dir('path_to_logs')->clear()) {
    echo 'Log files in `path_to_logs` folder were cleared successfully.';
} else {
    echo 'Log files in `path_to_logs` folder were cleared with errors.';
}

Working with Artisan CLI

Laravel GeoIP Log Cleaner have command can use easily with Artisan CLI. Example:

$ php artisan geoiplog:clear --path=/path/to/log/files --rotate=14

Please use each above command with option --help for details of usage. Example:

$ php artisan geoiplog:clear --help

License

The Laravel GeoIP Log Cleaner is open-source software licensed under the MIT license.

Thanks for use

Hopefully, this package is useful to you.