aic-international/laravel-chronos-logger is a laravel package providing a logging handler to send logs to a Chronos
Server.
You can install the package via composer:
composer require aic-international/laravel-chronos-loggerYou must add a new channel to your config/logging.php file:
// config/logging.php
'channels' => [
//...
'chronos' => [
'driver' => 'custom',
'via' => AicInternational\ChronosLogger\Logger::class,
'url' => env('LOG_CHRONOS_WEBHOOK_URL'),
'token' => env('LOG_CHRONOS_TOKEN'),
'level' => env('LOG_CHRONOS_LEVEL', 'debug'),
'labels' => [
'app' => env('APP_NAME'),
'env' => env('APP_ENV'),
],
],
];You can then provide the web-hook URL and token in your .env file:
LOG_CHRONOS_WEBHOOK_URL=https://example.com
CHRONOS_LOG_TOKEN=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX
You have two options: log only to chronos or add the channel to the stack
Simply change the .env variable to use the chronos channel
LOG_CHANNEL=chronos
Add the channel to the stack in the config/logging.php configuration:
// config/logging.php
'channels' => [
//...
'stack' => [
'driver' => 'stack',
'channels' => ['single', 'chronos'],
],
];Then make sure the logging channel is set to stack in your .env file:
LOG_CHANNEL=stack
Of course, you can send your log messages to multiple Chronos channels. Just create as many channels as desired in
config/logging.php and put them in the stack. Each channel should be named differently and should point to a different
web hook URL.
php artisan chronos:configOptional: provide another channel name:
php artisan chronos:config chronos_stagingphp artisan chronos:log-testOptional custom message:
php artisan chronos:log-test "Hello from Chronos!"Result:
- A test log entry will be sent to the configured
chronoschannel. - The console will display a confirmation:
✅ Test log sent: Hello from Chronos!
Tip: Use this command after installation or when changing configuration to quickly verify that everything is set up correctly.
You might encounter this exception alongside "cURL error 60: SSL certificate problem: unable to get local issuer certificate" while using/testing your web hook in a development enviroment. This occurs due to your local machine's inability to verify the server's SSL certificate.
-
Obtain the cacert.pem file from the curl website.
-
Store the cacert.pem file in a secure location on your computer, such as C:\xampp\php\extras\ssl\cacert.pem.
-
Access your php.ini file, typically found in your PHP installation directory.
-
Locate curl.cainfo = in php.ini. If it's commented out (begins with a ;), remove the semicolon.
-
Insert the path to cacert.pem you saved earlier. Example: curl.cainfo = "C:\xampp\php\extras\ssl\cacert.pem".
-
Save the php.ini file and restart your server to implement the changes.
- Got some ideas from RakInteractive/Chronos
- Got some ideas from vpratfr/laravel-discord-logger
- Got some ideas from GrKamil/laravel-telegram-logging
The MIT License (MIT). Please see License File for more information.