mbpcoder / laravel-monolog-rocketchat
Rocket Chat Handler for Monolog
v1.0
2025-05-17 14:19 UTC
Requires
- php: ^8.0
- ext-curl: *
- ext-mbstring: *
- monolog/monolog: ^1.0|^2.0|^3.0
README
β Why Another Logger?
Logging should be more than just saving data β it should drive action. Hereβs why π Rocket Chat Handler for Monolog π is a game-changer:
- π Real-Time Feedback β Instantly receive logs in your Rocket Chat.
- π§ Actionable Insights β Include useful context for quick understanding.
- π‘οΈ No Need for Sentry or Third-Party Services
- β‘ Immediate Alerts β Be notified of issues the moment they happen.
- π₯ Team Collaboration β Share logs in group chats for quick follow-up.
π― Installation
Install via Composer:
composer require mbpcoder/laravel-monolog-rocketchat
βοΈ Usage
Update your config/logging.php
file to configure the Rocket Chat logging channel.
β³ Running Logs in a Queue
If a queue name is set, logs will be processed asynchronously in the specified queue. Otherwise, they will run synchronously.
π§ Configuration Example
Modify your config/logging.php
file:
return [ 'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['single', 'rocketchat'], ], 'rocketchat' => [ 'driver' => 'monolog', 'level' => 'debug', 'handler' => TheCoder\MonologRocketChat\RocketChatBotHandler::class, 'handler_with' => [ 'token' => env('LOG_ROCKET_CHAT_BOT_TOKEN'), 'chat_id' => env('LOG_ROCKET_CHAT_CHAT_ID'), 'bot_api' => env('LOG_ROCKET_CHAT_BOT_API'), 'queue' => env('LOG_ROCKET_CHAT_QUEUE', null) ], 'formatter' => TheCoder\MonologRocketChat\RocketChatFormatter::class, 'formatter_with' => [ 'tags' => env('LOG_ROCKET_CHAT_TAGS', null), ], ], ], ];
π Customizing Log Settings at Runtime
You can dynamically set the bot token, chat ID while logging:
logger('message', [ 'token' => 'your_bot_token', 'chat_id' => 'your_chat_id' ]);
π Environment Variables
Ensure the following variables are set in your .env
file:
LOG_ROCKET_CHAT_BOT_TOKEN= LOG_ROCKET_CHAT_CHAT_ID= LOG_ROCKET_CHAT_BOT_API=
π License
This package is open-source and available under the MIT License. π