grkamil / laravel-telegram-logging

Send logs to Telegram chat via Telegram bot
MIT License
148 stars 36 forks source link

Allow config for ignoreEmptyContextAndExtra #20

Closed sauravkumal closed 3 years ago

sauravkumal commented 3 years ago

https://github.com/GrKamil/laravel-telegram-logging/blob/f746dbb2413afdaac7faa9465000e50b33a6b8e3/src/TelegramHandler.php#L98

possible quick solution: return new LineFormatter("%message% %context% %extra%\n",null, false, true);

Or can add them to config for flexibility

frknakk commented 3 years ago

I just had the same problem: The logs contain two extra square brackets at the end. So the original log message "The system is down!" is formatted to "The system is down! [] []".

The 4th parameter$ignoreEmptyContextAndExtra of LineFormatter constructor hides empty arrays from formatted output. Also see: https://stackoverflow.com/a/13971250/13448160

I can create a pull request for it if you want :) Why did you add a "help wanted" tag?

grkamil commented 3 years ago

I have fixed as you suggested. If someone want to make PR with flexible values (move the line formatter options to config) it would be great.