Coder Social home page Coder Social logo

thanhtaivtt / laravel-telegram-logger Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 14 KB

Laravel Send error log to Telegram Bot, Channel

Home Page: https://toidicode.com

PHP 100.00%
php php7 laravel telegram-bot laravel-logger laravel-telegram-logger

laravel-telegram-logger's Introduction

laravel-telegram-logger

Send Laravel log to Telegram Bot or Channel

Install

composer require thanhtaivtt/laravel-telegram-logger

Config

  • Add this code to the config/logging.php as a new channel:
'telegram' => [
            'driver' => 'custom',
            'via' => \Thanhtaivtt\TelegramLogger\TelegramLogger::class,
            'api_key' => env('TELEGRAM_API_KEY'),
            'chat_id' => env('TELEGRAM_CHAT_ID'),
            'send_log' => env('TELEGRAM_SEND_LOG', false),
        ],
  • And add telegram channel to current stack channel:

Eg:

'channels' => [
        'stack' => [
            'driver' => 'stack',
            'channels' => ['daily', 'telegram'],
            'ignore_exceptions' => false,
        ],
  • Define Telegram Bot Token and chat id on .env
TELEGRAM_API_KEY=BOT_TOKEN
TELEGRAM_CHAT_ID=BOT_ID
TELEGRAM_SEND_LOG=true

Description

Key Type Description
TELEGRAM_API_KEY String Token of Telegram Bot or Channel
TELEGRAM_CHAT_ID String Bot or Channel ID (Include the @ character)
TELEGRAM_SEND_LOG Boolean Specify whether to send the log or not

If you want to send the log in all other than local environments, you can set it as follows:

'telegram' => [
            'driver' => 'custom',
            'via' => \Thanhtaivtt\TelegramLogger\TelegramLogger::class,
            'api_key' => env('TELEGRAM_API_KEY'),
            'chat_id' => env('TELEGRAM_CHAT_ID'),
            'send_log' => env('APP_ENV') !== 'local',
        ],

How to create Telegram Bot?

Laravel Telegram Logger

laravel-telegram-logger's People

Contributors

thanhtaivtt avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

mrjavadseydi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.