承接 podvoyskiy/tg-logger 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

podvoyskiy/tg-logger

最新稳定版本:v2.0.0

Composer 安装命令:

composer require podvoyskiy/tg-logger

包简介

PHP library for sending logs, alerts, and exceptions to Telegram

README 文档

README

Simple PHP library to forward logs (info, debug, alerts, errors) to Telegram

Installing:

composer require podvoyskiy/tg-logger

Usage:

<?php

use Podvoyskiy\TgLogger\TelegramLogger;

class Telegram extends TelegramLogger
{
    protected static function setToken(): void
    {
        // example: get token from environment variable
        self::$token = (string)getenv('TELEGRAM_TOKEN');
    }
    
    protected function setChatsIds(): void
    {
        $this->chatsIds = [
            self::EXAMPLE_SUBSCRIBER => getenv('TELEGRAM_CHAT_ID')
        ];
    }
    
    public const EXAMPLE_SUBSCRIBER = 'example_subscriber';
    
    //if you need set cache storage for same messages. required redis/apcu extension (StorageType::REDIS|StorageType::APCU)
    //protected static ?StorageType $currentStorage = StorageType::REDIS;
    
    //if you need global setting limit on same messages (for example 30 min)
    //protected const TTL = 30 * 60; 
    
    //set values if you need to send messages only at certain times
    //protected const WORKING_HOURS_RANGE = [9, 18];
    
    //set to 0 if you don't need backtrace in message. default depth : 1
    //protected const BACKTRACE_DEPTH = 0;
    
    //List here the classes that should be excluded from backtrace
    //protected const EXCLUDED_CLASSES_FROM_BACKTRACE = [SomeClass::class];
}

Telegram::send(Telegram::EXAMPLE_SUBSCRIBER, 'Your message', LogLevel::INFO);

Telegram::warning(Telegram::EXAMPLE_SUBSCRIBER, 'Your warning', 60); //60 - ttl for this message

Telegram::sendDoc(Telegram::EXAMPLE_SUBSCRIBER, $pathToFile);

统计信息

  • 总下载量: 25
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-08