grkamil / laravel-telegram-logging Goto Github PK
View Code? Open in Web Editor NEWSend logs to Telegram chat via Telegram bot
License: MIT License
Send logs to Telegram chat via Telegram bot
License: MIT License
laravel.EMERGENCY: Unable to create configured logger. Using emergency logger. {"exception":"[object] (Error(code: 0): Class \"Logger\\TelegramHandler\" not found at /vendor/grkamil/laravel-telegram-logging/src/TelegramLogger.php:24)
[stacktrace]
#0 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(247): Logger\\TelegramLogger->__invoke()
#1 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(220): Illuminate\\Log\\LogManager->createCustomDriver()
#2 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(135): Illuminate\\Log\\LogManager->resolve()
#3 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(122): Illuminate\\Log\\LogManager->get()
#4 /vendor/laravel/framework/src/Illuminate/Log/LogManager.php(645): Illuminate\\Log\\LogManager->driver()
#5 /vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(274): Illuminate\\Log\\LogManager->error()
#6 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(182): Illuminate\\Foundation\\Exceptions\\Handler->report()
#7 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(226): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleException()
#8 /vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(250): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleShutdown()
#9 [internal function]: Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}()
#10 {main}
"}
laravel.ERROR: Declaration of Logger\TelegramHandler::write(array $record): void must be compatible with Monolog\Handler\AbstractProcessingHandler::write(Monolog\LogRecord $record): void {"userId":1,"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Declaration of Logger\\TelegramHandler::write(array $record): void must be compatible with Monolog\\Handler\\AbstractProcessingHandler::write(Monolog\\LogRecord $record): void at /vendor/grkamil/laravel-telegram-logging/src/TelegramHandler.php:75)
[stacktrace]
#0 {main}
"}
possible quick solution:
return new LineFormatter("%message% %context% %extra%\n",null, false, true);
Or can add them to config for flexibility
Problem:
When external services are down, I continuously receive messages about it, several messages per second.
Solution:
Make a setting for limiting the number of identical messages per unit of time.
I can do this and offer a pull-request. I think this can be done using the Cache facade. But I'm not sure if this is the best way. If there are other options, tell me and I will make a pull request.
Any possibility of creating a version that supports Lumen?
I can send to telegram only through a proxy. How add proxy?
Would it be possible to implement a custom getDefaultFormatter?
I would like to create my log in a specific format and with some user session data.
Hi, there is no latest version on packagist because of license error.
Could you fix it?
Problem 1
- Installation request for grkamil/laravel-telegram-logging ^0.1.2 -> satisfiable by grkamil/laravel-telegram-logging[0.1.2].
- Conclusion: remove laravel/framework v5.8.28
- Conclusion: don't install laravel/framework v5.8.28
- grkamil/laravel-telegram-logging 0.1.2 requires laravel/framework 5.6.|5.7. -> satisfiable by laravel/framework[5.6.x-dev, 5.7.x-dev].
- Can only install one of: laravel/framework[5.6.x-dev, v5.8.28].
- Can only install one of: laravel/framework[5.7.x-dev, v5.8.28].
- Installation request for laravel/framework (locked at v5.8.28, required as 5.8.*) -> satisfiable by laravel/framework[v5.8.28].
Hello, thanks for a great package!
I ran into an issue recently, where Telegram is failing to send a long error message with huge mysql query error.
And Telegram returned "HTTP request failed! HTTP/1.1 400 Bad Request".
It works with shorter message though.
Would you like me to find out the limit and send a pull request to substr the message?
Looks like the return type of formatText() should be changed from string to Illuminate\View\View
Could you add support for monolog 2.0?
thanks
I don't know if it's possible, but It would be great something like:
Log::channel('telegram')->setBotId('example')->setChatId('example')->info('Log!');
To log with its credentials without override the config credentials
I'm migrating my app to Laravel 11 and have issue with templates. I use the minimal template where I only display the message ie. {{ formatted }}, but for some reason the app name with the log type is also sent as a message to Telegram. Any ideas what could be the issue? Seems like the published template is not being used.
Uncaught TypeError: Return value of Logger\TelegramHandler::getConfigValue() must be of the type string, null returned
vendor/grkamil/laravel-telegram-logging/src/TelegramHandler.php:159
I got this error after upgraded to 1.8
When I customize the log, I have the link added and I don't want telegram to show the preview
If error message length over 4096 and i change template:
<b>{{ $appName }}</b> ({{ $level_name }})
Env: {{ $appEnv }}
<pre>[{{ $datetime->format('Y-m-d H:i:s') }}] {{ $appEnv }}.{{ $level_name }} {{ $formatted }}</pre>
Message break and I get two messages:
<b>Project</b> (ERROR)
Env: local
<pre>[2023-03-01 17:41:32] local.ERROR many text
and:
many text</pre>
When send messages to telegram as a response we get 400 error:
{
"ok": false,
"error_code": 400,
"description": "Bad Request: can't parse entities: Can't find end tag corresponding to start tag pre"
}
If not use wrap tag everything is fine.
Addition
I want 1 error = 1 message even if the size is over 4096. Example cut off and add ...
<b>Project</b> (ERROR)
Env: local
[2023-03-01 17:41:32] local.ERROR bla-bla-bla ...
Are there any plans to update accordingly?
Hello,
I want to send notification to multiple user so how can i pass multiple user's telegram id?
in Telegram API Docs, there is message_thread_id that is optional parameter to send message to group topic. Just add parameters to TelegramHandler.php/sendMessage and update the config
I have both environment staging & production. How to enable log telergam notif only when production? In staging just want log to file.
I'm sure my problem doesn't come from this package but I ran out of solution.
When I log a simple string Log::info('test'); it works perfectly in local.
But in production server (VPS), it does not. I don't know why. I checked everything. The logs are being written correctly in the logs. But when I set the LOG_CHANNEL to telegram, nothing happens. I tried putting "telegram" in the stack array. Nothing. Any idea ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.