Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sergeymakinen/yii2-telegram-log
Telegram log target for Yii 2
https://github.com/sergeymakinen/yii2-telegram-log
log logging logging-library notification notifications php php-library telegram yii2 yii2-extension
Last synced: 4 months ago
JSON representation
Telegram log target for Yii 2
- Host: GitHub
- URL: https://github.com/sergeymakinen/yii2-telegram-log
- Owner: sergeymakinen
- License: mit
- Archived: true
- Created: 2017-01-05T15:22:05.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-01-24T19:43:35.000Z (almost 4 years ago)
- Last Synced: 2024-09-18T22:33:00.744Z (4 months ago)
- Topics: log, logging, logging-library, notification, notifications, php, php-library, telegram, yii2, yii2-extension
- Language: PHP
- Homepage:
- Size: 579 KB
- Stars: 26
- Watchers: 8
- Forks: 13
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Telegram log target for Yii 2
[Telegram](https://telegram.org) log target for Yii 2.
![Screenshot](docs/README.png)
[![Code Quality](https://img.shields.io/scrutinizer/g/sergeymakinen/yii2-telegram-log.svg?style=flat-square)](https://scrutinizer-ci.com/g/sergeymakinen/yii2-telegram-log) [![Build Status](https://img.shields.io/travis/sergeymakinen/yii2-telegram-log.svg?style=flat-square)](https://travis-ci.org/sergeymakinen/yii2-telegram-log) [![Code Coverage](https://img.shields.io/codecov/c/github/sergeymakinen/yii2-telegram-log.svg?style=flat-square)](https://codecov.io/gh/sergeymakinen/yii2-telegram-log) [![SensioLabsInsight](https://img.shields.io/sensiolabs/i/8b4f3236-7c78-42d1-8355-54605598d941.svg?style=flat-square)](https://insight.sensiolabs.com/projects/8b4f3236-7c78-42d1-8355-54605598d941)
[![Packagist Version](https://img.shields.io/packagist/v/sergeymakinen/yii2-telegram-log.svg?style=flat-square)](https://packagist.org/packages/sergeymakinen/yii2-telegram-log) [![Total Downloads](https://img.shields.io/packagist/dt/sergeymakinen/yii2-telegram-log.svg?style=flat-square)](https://packagist.org/packages/sergeymakinen/yii2-telegram-log) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
## Installation
The preferred way to install this extension is through [composer](https://getcomposer.org/download/).
Either run
```bash
composer require "sergeymakinen/yii2-telegram-log:^2.0"
```or add
```json
"sergeymakinen/yii2-telegram-log": "^2.0"
```to the require section of your `composer.json` file.
## Usage
First [create a new bot](https://core.telegram.org/bots#6-botfather) and obtain its token. It should look like `123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11`.
You will also need a [chat ID](https://stackoverflow.com/questions/31078710/how-to-obtain-telegram-chat-id-for-a-specific-user) to send logs to. You can use the [`@get_id_bot`](https://telegram.me/get_id_bot) bot to obtain it. It should look like `123456789`.
Then set the following Yii 2 configuration parameters:
```php
'components' => [
'log' => [
'targets' => [
[
'class' => 'sergeymakinen\yii\telegramlog\Target',
'token' => '123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11',
'chatId' => 123456789,
],
],
],
],
```## Configuration
By default `yii\log\Logger` error levels are mapped to emojis (you can tweak them in the `levelEmojis` property):
| Error level | Emoji
| --- | ---
`Logger::LEVEL_ERROR` | ☠️
`Logger::LEVEL_WARNING` | ⚠️
`Logger::LEVEL_INFO` | ℹ️
`Logger::LEVEL_TRACE` | 📝It's also possible to disable notifications - entirely or per logger level (look at the `enableNotification` property), for example:
```php
public $enableNotification = [
Logger::LEVEL_ERROR => true,
Logger::LEVEL_WARNING => false,
Logger::LEVEL_INFO => false,
];
```This will disable notifications for warning and info level messages and enable them for other levels (honestly, you can omit the `LEVEL_ERROR` definition here as it's `true` by default).