abergasov/telegram_logger
Composer 安装命令:
composer require abergasov/telegram_logger
包简介
Telegram php logger
README 文档
README
PHP logger for web site/app
Example messages telegram/slack
Instalation
composer require abergasov/telegram_logger
Usage
const INFO_CHAT = 0;
const ERROR_CHAT = 1;
const CONTACT_CHAT = 2;
$logger = new TelegramLogger([
'token' => SET_YOUR_TOKEN_HERE,
'chats' => [
INFO_CHAT => -199024103,
ERROR_CHAT => -293646246,
CONTACT_CHAT => -305488244,
... add more or less if need
],
'trace_dir' => __DIR__ . '/trace/logs',
'decorate_url' => 'https://example.com/trace/logs',
'logs' => [
'access_log' => '/home/admin/web/my_site/logs/access_log.log',
'error_log' => '/home/admin/web/my_site/logs/error_log.log',
]
]);
$logger->addSlackConfig([
'token' => SET_YOUR_SLACK_TOKEN_HERE,
'channels' => [
INFO_CHAT => 'GF4UTEHGB',
ERROR_CHAT => 'GF4UTEHGB',
CONTACT_CHAT => 'GF4UTEHGB',
],
]);
$result = $logger->sendMessage(INFO_CHAT, 'Hello, I need help', 'Additional info 1', 'Additional info 2', 'Additional info 3');
echo ($result ? 'Info message was send' : 'Troubles in send messages') . PHP_EOL;
try {
throw new RuntimeException('Something went wrong in this world');
} catch (Throwable $t) {
$logger->sendMessage(ERROR_CHAT, 'Exception in script', $t);
}
Config documentation
| Key | Type | Description |
|---|---|---|
| token | String | bot token |
| chats | Array | list of chats to send message. See example.php |
| trace_dir | String/Boolean | By default false Directory where should put trace log file. Must be writable. For example /home/admin/web/site/public_html/trace/logs |
| decorate_url | String | Empty by default. Url for access to file via browser. For example "https://example.com/trace/logs" |
| logs | Array | Empty by default. path to acess log and error logs. Must be readable. See example.php for details |
Creating telegram bot tutorial
- Find BotFather.
- Send /newbot.
- Set up name and bot-name for your bot.
- Get token and add it to your .env file.
- Find your bot (BotFather already generate link to it in last message).
- Send one or few messages to him.
- Open next url https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates and find chat_id.
- find @myidbot and send him /getid for personal chat
- find @myidbot add him to group and send him /getgroupid@myidbot for chat id
abergasov/telegram_logger 适用场景与选型建议
abergasov/telegram_logger 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 189 次下载、GitHub Stars 达 1, 最近一次更新时间为 2019 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「composer」 「logger」 「telegram」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 abergasov/telegram_logger 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 abergasov/telegram_logger 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 abergasov/telegram_logger 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Workflow logger
HTTP request logger middleware for Laravel
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
High-performance, zero-dependency PSR-3 logger for MonkeysLegion with structured logging, handlers, processors, and PHP 8.4 features.
Simple ASCII output of array data
统计信息
- 总下载量: 189
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-07-08



