Metadata-Version: 2.4
Name: log-cleanup
Version: 0.1.2
Summary: Automated log file cleanup with scheduling support
Author-email: Swetha T <tswetha3188@gmail.com>
License: MIT
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: System :: Logging
Classifier: Topic :: System :: Systems Administration
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: APScheduler>=3.10.0
Requires-Dist: tzlocal>=5.0.0
Dynamic: license-file

Yes. Here’s a README-ready section with examples for the main ways users can use it.

```python
# log_cleanup examples

from log_cleanup import LogCleaner
```

## 1. Basic cleanup

Deletes old `.log` and `.txt` files older than the retention period.

```python
from log_cleanup import LogCleaner

cleaner = LogCleaner(
    log_location="/var/log/myapp",
    retention_days=30,
)

result = cleaner.clean()
print(result)
```

## 2. Dry run

Shows what would be deleted without actually removing files.

```python
from log_cleanup import LogCleaner

cleaner = LogCleaner(
    log_location="/var/log/myapp",
    retention_days=30,
    dry_run=True,
)

result = cleaner.clean()
print(result)
```

## 3. Custom file extensions

Clean only selected file types.

```python
from log_cleanup import LogCleaner

cleaner = LogCleaner(
    log_location="/var/log/myapp",
    retention_days=14,
    file_extensions={".log", ".txt", ".out", ".err"},
)

result = cleaner.clean()
print(result)
```

## 4. Custom cleanup log file

Write cleanup activity to a custom log file.

```python
from log_cleanup import LogCleaner

cleaner = LogCleaner(
    log_location="/var/log/myapp",
    retention_days=30,
    cleanup_log="/var/log/myapp/log-cleanup.log",
)

result = cleaner.clean()
print(result)
```

## 5. Get statistics only

Shows file stats without deleting anything.

```python
from log_cleanup import LogCleaner

cleaner = LogCleaner(
    log_location="/var/log/myapp",
    retention_days=30,
)

stats = cleaner.get_stats()
print(stats)
```

Example output:

```python
{
    "total_files": 120,
    "total_size": 104857600,
    "old_files": 42,
    "old_files_size": 31457280
}
```

## 6. Use the scheduler

Run cleanup automatically on a schedule.

```python
from log_cleanup.scheduler import LogCleanupScheduler

scheduler = LogCleanupScheduler(
    log_location="/var/log/myapp",
    retention_days=30,
    schedule_type="cron",
    cron_params={
        "day": 1,
        "hour": 5,
        "minute": 0,
    },
)

scheduler.start()
```

## 7. Interval scheduling

Run cleanup every 7 days.

```python
from log_cleanup.scheduler import LogCleanupScheduler

scheduler = LogCleanupScheduler(
    log_location="/var/log/myapp",
    retention_days=30,
    schedule_type="interval",
    interval_params={
        "days": 7,
    },
)

scheduler.start()
```

## 8. Run cleanup immediately from scheduler

Useful when you want the scheduler object but also need a manual run.

```python
from log_cleanup.scheduler import LogCleanupScheduler

scheduler = LogCleanupScheduler(
    log_location="/var/log/myapp",
    retention_days=30,
)

scheduler.run_now()
```

## 9. Command-line usage

```bash
log-cleanup --log-path /var/log/myapp --retention-days 30 --run-now
```

Dry run:

```bash
log-cleanup --log-path /var/log/myapp --retention-days 30 --run-now --dry-run
```

Stats:

```bash
log-cleanup --log-path /var/log/myapp --retention-days 30 --stats
```

Schedule:

```bash
log-cleanup --log-path /var/log/myapp --retention-days 30 --schedule
```
