Git Product home page Git Product logo

yii2-log-telegram's Introduction

Telegram log target for Yii 2

Telegram log target for Yii 2.

Fork from sergeymakinen/yii2-telegram-log

Installation

The preferred way to install this extension is through composer.

Either run

composer require "spayn/yii2-log-telegram"

Usage

First create a new bot and obtain its token. It should look like 123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11.

You will also need a chat ID to send logs to. You can use the @get_id_bot bot to obtain it. It should look like 123456789.

Then set the following Yii 2 configuration parameters:

'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:

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).

yii2-log-telegram's People

Contributors

sergeymakinen avatar spayn112 avatar

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.