- How do I install and set up averor/simple-logger in Laravel?
- Run `composer require averor/simple-logger`, then configure it in `config/logging.php` under a custom channel. Bind the logger to Laravel’s container via `via` and set a handler (e.g., file or CLI). Start logging with `Log::channel('simple_logger')->info('Your message')`.
- Does this package work with Laravel’s built-in Log facade?
- Yes, but you must configure it as a custom channel in `config/logging.php`. It won’t integrate natively with Laravel’s `Log::channel()` without manual setup. Use it alongside existing channels for flexibility.
- What Laravel versions does averor/simple-logger support?
- The package requires **PHP 8.0+** and works with **Laravel 8.x+**. It’s designed for modern Laravel but lacks explicit version pinning, so test compatibility if using Laravel 9+.
- Can I add context data (e.g., variables) to log entries?
- Yes, the logger supports contextual data via the `log()` method’s second argument. Pass an associative array (e.g., `['user_id' => 123]`) to include structured metadata with each log entry.
- Is averor/simple-logger suitable for production environments?
- It’s lightweight and stable for basic logging, but lacks features like log rotation or async handling. For production, pair it with a custom handler (e.g., file with rotation) or consider Monolog for advanced needs.
- How does this compare to Laravel’s default Monolog setup?
- averor/simple-logger is **10x lighter** (~50KB vs. Monolog’s ~10MB) and avoids Monolog’s complexity. Use it for simple needs; Monolog is better for structured logs, queues, or multi-handler setups.
- Can I use this for structured logging (e.g., JSON format)?
- No, it outputs plain text by default. For JSON logs, wrap the logger in a decorator or use a custom handler to format entries before writing. Example: `json_encode(['level' => $level, 'message' => $message])`.
- Will this work in serverless environments (e.g., AWS Lambda)?
- Yes, but ensure your handler (e.g., `StreamHandler` to `php://stdout`) writes to a supported output. Avoid file handlers in serverless—use environment variables or custom handlers for cloud logging services.
- How do I test averor/simple-logger in my Laravel app?
- Mock the logger in tests using Laravel’s `Log::shouldReceive()` or replace the container binding with a test double. Verify log levels (e.g., `debug()`, `error()`) and context data are captured correctly.
- Are there plans to add Laravel-specific features (e.g., Log::channel() support)?
- The package focuses on simplicity and PSR-14 compliance. While no Laravel-specific features are planned, you can extend it (e.g., create a facade wrapper) or use it as a fallback logger for non-critical paths.