Giter VIP home page Giter VIP logo

telegram-logger's Introduction

Telegram Logger

Latest Version on Packagist

This extension allows you to see your project logs in real time using Telegram app.

How To Install

via Composer require command (composer 2 is required):

Just type into the CLI in your project root:

composer require electrobayan/telegram-logger

via updating composer.json:

{
    "require": {
        "electrobayan/telegram-logger": "^1.0"
    }
}

Then run in you CLI:

composer install

How To Use

Quick example:

You will have to create a Telegram bot and a channel. Check the user guide here. Then just do the following:

$infoLogger = new \TelegramLogger\Creator\InfoPoster('Telegram Key Goes here', '@your_telegram_channel_name');
$infoLogger->post('test', ['key_1' => 'value_1', 'key_2' => 'value_2'], ['tag1', 'tag2']);

Details

There 3 types of log messages:

  • Info
  • Warning
  • Error
You are free to create new if needed. Each of these types of messages has their own icons, frame and titles. Depending on what type you need you should use an appropriate Poster: `InfoPoster`, `ErrorPoster` or `WarningPoster`.
$errorLogger = new \TelegramLogger\Creator\ErrorPoster('Telegram Key Goes here', '@your_telegram_channel_name');
$warningLogger = new \TelegramLogger\Creator\WarningPoster('Telegram Key Goes here', '@your_telegram_channel_name');
$infoLogger = new \TelegramLogger\Creator\InfoPoster('Telegram Key Goes here', '@your_telegram_channel_name');

After the poster created all is left is just to call post method.

$errorLogger->post('Error Message', ['key_1' => 'value_1', 'key_2' => 'value_2'], ['tag1', 'tag2']);
$warningLogger->post('Warning Message', ['key_1' => 'value_1', 'key_2' => 'value_2'], ['tag1', 'tag2']);
$infoLogger->post('Info Message', ['key_1' => 'value_1', 'key_2' => 'value_2'], ['tag1', 'tag2']);

Also, you can pass optional extra params if needed as an array key => value. Both key and value will be posted into the channel. You can pass optional tags if needed as an array key => value. Only values will be posted into the channel.

telegram-logger's People

Contributors

electrobayan avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

akbarazimifar

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.