Download the PHP package digitaldev-lx/log-hole without Composer
On this page you can find all versions of the php package digitaldev-lx/log-hole. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download digitaldev-lx/log-hole
More information about digitaldev-lx/log-hole
Files in digitaldev-lx/log-hole
Package log-hole
Short Description LogHole is a modern, flexible Laravel logging package that supports Redis and database drivers. Designed for seamless integration with Laravel's Log facade, it leverages PHP attributes for a clean and powerful logging experience.
License MIT
Informations about the package log-hole
Laravel LogHole
LogHole is a modern, flexible Laravel logging package that supports database drivers. Designed for seamless integration with Laravel's Log facade, it leverages PHP attributes for a clean and powerful logging experience.
Requirements
Release | PHP | Laravel |
---|---|---|
1.0.0 | >= 8.2 | 10 |
Installation
Install the package via Composer:
You must publish the configuration file:
Configurations
In the configuration file, specify the driver you'd like to use (database). By default, the package supports the database driver.
Example Configuration for Database:
.env file
configuration file logging.php
Use Middleware:
Laravel 10.x
Laravel 10.x uses the web middleware group by default. To log all requests, add the LogHole middleware to the web group in the app/Http/Kernel.php file:
Laravel 11.x
Laravel 11.x also uses the web middleware group by default. To log all requests, add the LogHole middleware to the withMiddleware method in the bootstrap/app.php file:
Using PHP Attributes
LogHole offers PHP attribute-based logging to automatically log actions when specific attributes are applied to methods or classes. To use the Loggable attribute, it is necessary to implement the LogHole middleware.
With the middleware in place, all calls to methods annotated with Loggable will be logged as specified.
Usage
Log messages through Laravel’s Log facade, which will route logs to your chosen storage driver (Redis or database):
View logs
The LogHole dashboard provides a user-friendly interface for viewing logs. You can filter logs by date, level, and message, as well as search for specific log entries.
Laravel Pail
You can use Laravel Pail to view logs in real-time. Laravel Pail is a powerful tool for monitoring logs and debugging applications. It provides a user-friendly interface for viewing logs in real-time, as well as detailed information about log entries.
LogHole Tail Command
The log-hole:tail
command allows you to retrieve logs from the database based on specific log levels or date ranges. This command is highly configurable, enabling you to filter logs by level and date range to get precisely the information you need.
Usage
To run the log-hole:tail
command, use the following syntax:
Options
The command provides several options to customize the logs you want to retrieve:
--emergency
: Fetch only logs with the "EMERGENCY" level.--critical
: Fetch only logs with the "CRITICAL" level.--error
: Fetch only logs with the "ERROR" level.--warning
: Fetch only logs with the "WARNING" level.--notice
: Fetch only logs with the "NOTICE" level.--info
: Fetch only logs with the "INFO" level.--debug
: Fetch only logs with the "DEBUG" level.--from=
: Specify the starting date to filter logs, using a date format (e.g.,2024-10-01
).--to=
: Specify the end date to filter logs, using a date format (e.g.,2024-10-31
).--take=
: Limit the number of log entries displayed (defaults to 10 if not specified).--purge
: Purge all logs from the database.
Note: If no specific level is selected, the command will default to retrieving logs at the "ALL" level.
Examples
Here are some examples of how to use the log-hole:tail
command effectively:
Fetch all logs from the database (without --take
tag it will take last 10 logs by default)
Fetch only error-level logs from a specific date range
Fetch only warning-level logs
Fetch critical logs with a limit of 5 entries
Fetch info-level logs from a specific date onwards
Purge all logs from the database
Output
The command displays logs in a table format with the following columns:
- ID: The unique identifier for the log entry.
- Level: The log level (e.g., "ERROR", "INFO").
- Message: The log message.
- Context: Additional context information.
- Logged At: The date and time the log entry was created.
A table example is shown below:
Conclusion
LogHole simplifies the logging process in Laravel applications, making it easier to monitor and debug your code. With its powerful features and easy setup, you can enhance your logging experience today.
License
digitaldev-lx/log-hole is open-sourced software licensed under the MIT license.
About DigitalDev
DigitalDev is a web development agency based on Lisbon, Portugal. We specialize in Laravel, Livewire, and Tailwind CSS. Codeboys is our special partner and we work together to deliver the best solutions for our clients.
All versions of log-hole with dependencies
spatie/laravel-package-tools Version ^1.16
illuminate/contracts Version ^10.0||^11.0