confetticode/laravel-logging

Integrate multi log channels with Laravel

v0.2.0 2023-08-27 23:48 UTC

This package is auto-updated.

Last update: 2024-04-28 01:19:10 UTC


README

Build Status Total Downloads Latest Stable Version License

Installation

You can install the package via composer:

composer require confetticode/laravel-logging

Configure your expected channel variables:

LOG_MAIL_DRIVER=smtp
LOG_MAIL_LEVEL=error
LOG_MAIL_FROM=noreply@example.com
LOG_MAIL_TO=devops@example.com

LOG_TELEGRAM_LEVEL=error
LOG_TELEGRAM_API_KEY=1xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
LOG_TELEGRAM_CHAT_ID="@channel_or_group_id"

Usage

Send a log entry to mail or telegram:

# Sending a log entry via mail.
Log::channel('mail')->info('Test mail log channel.');

# Sending a log entry via telegram.
Log::channel('telegram')->info('Test telegram log channel.');

Or update the log stack to include telegram and mail channel:

<?php
// config/logging.php
return [
   'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily', 'telegram', 'mail'],
            'ignore_exceptions' => false,
        ],
     ],
];

Contributing

  1. Clone the repository from GitHub.
  2. Checkout a new branch.
  3. Install composer dependencies and run tests first.
    composer install
    composer run test
  4. Make any changes that you need and run test again.
  5. Finally, submit your pull request.

License (MIT)

The MIT License (MIT). Please see License File for more information.