Download the PHP package mrmmg/laravel_loggify without Composer
On this page you can find all versions of the php package mrmmg/laravel_loggify. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mrmmg/laravel_loggify
More information about mrmmg/laravel_loggify
Files in mrmmg/laravel_loggify
Package laravel_loggify
Short Description A Laravel package that provides an easy and efficient way to store log messages using Redis.
License MIT
Informations about the package laravel_loggify
Loggify
Managing Laravel Logs with Tags and Enhanced Options.
The meaning
Based on ChatGPT response "Loggify" is not a standard word in the English language, and it doesn't have an established definition. you can define it as something like: To streamline or enhance the process of creating and managing logs or records, especially in a digital or data-driven context. This may involve automating log generation, improving log organization, or making logs more user-friendly for analysis and monitoring purposes.
What do this package?
This package assists Laravel developers in storing application logs in a Redis database (currently supported) and provides a convenient system for categorizing these logs using tags. This allows developers to easily navigate through logs based on their assigned tags.
Getting Started
Before Install
Since this package utilizes Redis to store and manage logs, it's important to configure Laravel to work seamlessly with Redis. Additionally, make sure to install the necessary Redis requirements for Laravel, such as predis
.
Installation
Next, you'll need to publish the Loggify assets and configuration by running:
This command create loggify.php
configuration file in config
directory and create loggify assets in public/verndor/loggify
.
Configuration
The loggify.php
configuration file is self-documented with comment blocks. Nevertheless, I will provide an explanation for clarity:
Database and Redis
Similar to Laravel config/database.php
, this section describes the Redis connection settings, which you can customize to fit your requirements. By default, all logs are stored in Redis database 10.
Log Expiration
Redis is an in-memory database, and it's crucial to manage memory usage for logs. Therefore, you can specify how many seconds Redis should retain log items. By default, log items are retained for 1 day, which equals 86,400 seconds.
Tag Expiration
This option controls whether tags must expire or not. If you set it to a positive number, it indicates the number of seconds each tag can remain in the database. By default, it is set to false
, which means logs will not expire.
Log Tag Limits
This option will control how many log items each log tag can hold.
Pagination Limit
This option will control web panel each page max items. Default value is 100.
Usage
By using the Laravel Log Facade, you can integrate Loggify.
Examples
Where are the enhanced options?
The second parameter of Laravel log methods, referred to as context, is leveraged by Loggify to manage both log 'tags' and 'extra' log data. Let's continue with the previous example:
Great! You've successfully created a log tagged with MY_CUSTOM_TAG
. You can use as many tags as you need; there are no set limits.
To add extra data to the log context:
Other elements within the context are stored under the context key in the log stack, following the default Laravel behavior.
In the above example, the request_data is stored in the context, while the tags and extra are stored in other parts of the log.
Trace System
Loggify can assist you in debugging and identifying issues within your application by automatically storing the PHP debug backtrace feature. You don't need to take any additional steps; Loggify stores the backtrace for logs of the following types:
- debug
- alert
- critical
- emergency
- error
- warning
Examples
All the log examples mentioned above store the debug backtrace in the database, and you can view them in the Loggify web panel.
The Default Tags
By default, Loggify add two tags to your tags, ALL_LOGS
and LOG_TYPE_{laravel_log_type}
. for example:
The log mentioned above can be located in the web panel by filtering with the ALL_LOGS
, LOG_TYPE_INFO
, and INFO
tags.
Web Panel
To view the stored logs, open a web browser and navigate to the yourappurl.example/loggify
route.
Filter Tag Logs
By passing the log tag after that url the Loggify shows the tag logs, for example yourappurl.example/loggify/ALERT
show all logs that tagged with ALERT
tag.
Result Limit
By passing a ?limit=number
to Loggify route, you can control how many items must be show in web panel, for example if you set yourappurl.example/loggify?limit=1000
the latest 1000 elements shown in panel.
Web Panel Authorization
As logs can contain sensitive data, access control for the Loggify panel can be managed by the following gate in a production environment:
Note: A suitable place to add this gate is in the AuthServiceProvider
within the app/Providers
directory.
The closure function accepts a single argument, which is the authenticated user object. You can utilize this object to determine whether the user can access the /loggify route or not. Please keep in mind that the closure must return a boolean.
Screenshots
Dark/Light Theme
Log with Trace
Tags Information
I need your help 🤝
We welcome contributions from the community to help enhance this package further. If you'd like to collaborate and make it even better, please feel free to get involved.
Todo
- [x] Fix Trace System Issues
- [x] Implement web panel authorization
- [x] Implement tag items limit
- [x] Implement tag expiration
- [x] Implement pagination for web panel
- [ ] Implement tests
- [ ] Make Better document and GitHub pages
- [ ] Re-Design WebPanel