All Projects → grkamil → laravel-telegram-logging

grkamil / laravel-telegram-logging

Licence: MIT license
Send logs to Telegram chat via Telegram bot

Programming Languages

PHP
23972 projects - #3 most used programming language
Blade
752 projects

Projects that are alternatives of or similar to laravel-telegram-logging

winston-telegram
A Telegram transport for winston
Stars: ✭ 28 (-70.53%)
Mutual labels:  telegram-bot, logger
vcplayerbot
Play songs directly in telegram voice chats.
Stars: ✭ 48 (-49.47%)
Mutual labels:  telegram-bot
compress-pdf-tg-bot
A Telegram bot can compress the size of PDF documents. Useful for digital documentations.
Stars: ✭ 24 (-74.74%)
Mutual labels:  telegram-bot
video-encoder-bot
A Telegram bot to encode videos files via ffmpeg.
Stars: ✭ 75 (-21.05%)
Mutual labels:  telegram-bot
QwerteeTelegramBot
This bot shows you today's posts from Qwertee.
Stars: ✭ 18 (-81.05%)
Mutual labels:  telegram-bot
seas-logger
An effective,fast,stable log package for PHP.
Stars: ✭ 46 (-51.58%)
Mutual labels:  logger
PoShLog
🔩 PoShLog is PowerShell cross-platform logging module. It allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog - https://serilog.net/
Stars: ✭ 108 (+13.68%)
Mutual labels:  logger
FreeSteamGames-TelegramBot
A Telegram Bot that sends you a message when a game on steam is free
Stars: ✭ 35 (-63.16%)
Mutual labels:  telegram-bot
ptkdev-logger
🦒 Beautiful Logger for Node.js: the best alternative to the console.log statement
Stars: ✭ 117 (+23.16%)
Mutual labels:  logger
File-Sharing-Bot
Telegram Bot to store Posts and Documents and it can Access by Special Links.
Stars: ✭ 867 (+812.63%)
Mutual labels:  telegram-bot
BooksAndBot
Telegram inline bot. Search for books and share them in a conversation
Stars: ✭ 26 (-72.63%)
Mutual labels:  telegram-bot
LoggingAdvanced
Improved and patched .NET Core console logger.
Stars: ✭ 20 (-78.95%)
Mutual labels:  logger
forward-bot
Use Telegram to chat with your QQ friends.
Stars: ✭ 23 (-75.79%)
Mutual labels:  telegram-bot
pinterest-telegram-bot
Downloads Pinterest image from the given Pinterest shared URL and sends it back in telegram
Stars: ✭ 22 (-76.84%)
Mutual labels:  telegram-bot
fp-telegram
Wrapper classes library for telegram bots API (FreePascal)
Stars: ✭ 59 (-37.89%)
Mutual labels:  telegram-bot
react-native-logger
Async aware logger for react-native with grouping and filter feature
Stars: ✭ 20 (-78.95%)
Mutual labels:  logger
aiogram-bot-template
Template for creating scalable bots with aiogram
Stars: ✭ 175 (+84.21%)
Mutual labels:  telegram-bot
tdlight-telegram-bot-api
The TDLight Telegram Bot API is an actively enhanced fork of the original Bot API, featuring experimental user support, proxies, unlimited files size, and more.
Stars: ✭ 71 (-25.26%)
Mutual labels:  telegram-bot
telegram
📚 Golang bindings for Telegram API
Stars: ✭ 15 (-84.21%)
Mutual labels:  telegram-bot
grouphelperbot
A Telegram Bot made to help group admins, with Italian/English support.
Stars: ✭ 26 (-72.63%)
Mutual labels:  telegram-bot

Laravel Telegram logger

Send logs to Telegram chat via Telegram bot

Install


composer require grkamil/laravel-telegram-logging

Define Telegram Bot Token and chat id (users telegram id) and set as environment parameters. Add to .env

TELEGRAM_LOGGER_BOT_TOKEN=id:token
TELEGRAM_LOGGER_CHAT_ID=chat_id

Add to config/logging.php file new channel:

'telegram' => [
    'driver' => 'custom',
    'via'    => Logger\TelegramLogger::class,
    'level'  => 'debug',
]

If your default log channel is a stack, you can add it to the stack channel like this

'stack' => [
    'driver' => 'stack',
    'channels' => ['single', 'telegram'],
]

Or you can simply change the default log channel in the .env

LOG_CHANNEL=telegram

Publish config file and views

php artisan vendor:publish --provider "Logger\TelegramLoggerServiceProvider"

Telegram Logging Formats

You can choose among two different formats that you can specify in the .env file like this :

# Use a minimal log template
TELEGRAM_LOGGER_TEMPLATE = laravel-telegram-logging::minimal

# Or use the backward compatible one (default setting used even without inserting this row)
TELEGRAM_LOGGER_TEMPLATE = laravel-telegram-logging::standard

It is possible to create other blade templates and reference them in the TELEGRAM_LOGGER_TEMPLATE entry

Create bot

For using this package you need to create Telegram bot

  1. Go to @BotFather in the Telegram
  2. Send /newbot
  3. Set up name and bot-name for your bot.
  4. Get token and add it to your .env file (it is written above)
  5. Go to your bot and send /start message

Change log template at runtime

  1. Change config for template.
config(['telegram-logger.template'=>'laravel-telegram-logging::custom'])
  1. Use Log as usual.

Configuring a different chat id or token per channel

  1. Add chat_id or token to channels in config/logging.php. Overrides config('telegram.chat_id').
[
    'channels' => [
        [
            'company' => [
                'driver' => 'custom',
                'via' => TelegramLogger::class,
                'chat_id' => env('TELEGRAM_COMPANY_CHAT_ID'),
                'token' => env('TELEGRAM_COMPANY_BOT_TOKEN'),
                'level' => 'debug'
            ],

            'operations' => [
                'driver' => 'custom',
                'via' => TelegramLogger::class,
                'chat_id' => env('TELEGRAM_OPERATIONS_CHAT_ID'),
                'token' => env('TELEGRAM_OPERATIONS_BOT_TOKEN'),
                'level' => 'debug'
            ]
        ]
    ]
]
  1. Use Log as usual.

Lumen support

To make it work with Lumen, you need also run two steps:

  1. Place config/telegram-logger.php file with following code:
<?php

return [
    // Telegram logger bot token
    'token' => env('TELEGRAM_LOGGER_BOT_TOKEN'),

    // Telegram chat id
    'chat_id' => env('TELEGRAM_LOGGER_CHAT_ID'),
    
    // you can define your custom template for message
    // e.g: logging.template
    // 'template' => 'some your view path'
];
  1. Uncomment $app->withFacades(); and configure the file $app->configure('telegram-logger'); at bootstrap/app.php
  2. Place default Laravel/Lumen logging file to config/logging.php (to add new channel).
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].