Giter Club home page Giter Club logo

monolog-telegram's Introduction

monolog-telegram

Telegram Handler for php monolog which allows you to log messages into telegram channels using bots .

Latest Stable Version Total Downloads License

Screenshot


telegram handler demo screenshot

Installation


Install using composer:

composer require rahimi/monolog-telegram  

Usage

it is just like other monolog handlers, you need to pass below paramaters to telegramhandler object:

  • $token your bot token provided by BotFather
  • $channel your telegram channel userName
  • $date_default_timezone_set is the timezone identifier, like 'UTC' or 'Europe/Lisbon', that will be used as the default timezone by all date/time functions (optional, default value 'UTC')
  • $dateFormat pass date format (optional, default value 'Y-m-d H:i:s')
  • $timeOut timeout value in seconds for connection to Telegram servers when sending the log message (optional, default value 100). Use 0 to wait indefinitely.

Examples

Now Simply use it like this :

require 'vendor/autoload.php';
use Monolog\Logger;
use rahimi\TelegramHandler\TelegramHandler;
$log = new Logger('TelegramHandler');
$log->pushHandler(new TelegramHandler($token,$channel,'UTC','F j, Y, g:i a',60));


$log->info('hello world !');
/**
* There is 8 level of logging
*/
$log->notice('hello world !');
$log->info('hello world !');
$log->debug('hello world !');
$log->warning('hello world !');
$log->critical('hello world !');
$log->alert('hello world !');
$log->emergency('hello world !');
$log->error('hello world !');


/**
* Optionally you can pass second paramater such as a object
**/
$log->info('user just logged in !',['user'=>$user]);

License

This tool in Licensed under MIT, so feel free to fork it and make it better that it is !

monolog-telegram's People

Contributors

7-zete-7 avatar bu4ak avatar moeinrahimi avatar rvalitov avatar worldofwarcraftfa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

monolog-telegram's Issues

Respect more monolog standard output

Usually in monolog we can print a line like
BELogger.INFO: Params {"name":"Jane"} {"dummy":"Hello world!"}

Where

  • BELogger is the name of the logger
  • .INFO is the level of this log row
  • Params is the log message
  • {"name":"Jane"} is the optional attribute
  • {"dummy":"Hello world!"}` is the extra record usually done by processor

using telegram I think could be useful to see the entire structure of the message

  • I can't see the name of the logger
  • I think the level is expressed by Icon
  • I can see the message
  • I can see the attribute
  • I can't see the extra record

The Handler changes the default time zone settings

I think it's a bug. The handler must not change the date using the date_default_timezone_set. You can still use the provided argument in constructor for date formatting, but without using the date_default_timezone_set function. Have a look at NormalizeFormatter how they handle this situation without using the date_default_timezone_set function.

The Handler does not support bubble and log level options

Usually each handler has 2 vital options minimum (example):

  • log level - The minimum logging level at which this handler will be triggered
  • bubble - Whether the messages that are handled can bubble up the stack or not

It would be great if you could add those options, otherwise it's problematic to use your handler in existing code.

Timeout option

Can you please add a timeout option for the Web request?

rahimi\TelegramHandler function write

$date = $record['datetime']->format("Y-m-d h:m"); Please replace on $date = $record['datetime']->format("Y-m-d h:i"); Since in php "m" is a month, and "i" is a minute
I wanted to be able to change the date format using set methods.
Thank you!

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.