Skip to content

Integrate RoadRunner logger #156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog][keepachangelog] and this project adher
### Added

- gRPC client support
- Integrate with RoadRunner Logger

## Unreleased

Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ This package provides complete Laravel integration with RoadRunner, offering:
- [gRPC Client](#grpc-client)
- [Temporal](#temporal)
- [Custom Workers](#custom-workers)
- [Integrate with RoadRunner Logger](#integrate-with-roadrunner-logger)
- [Support](#support)
- [License](#license)

Expand Down Expand Up @@ -399,6 +400,28 @@ return [
The key in the `workers` array should match the value of the `RR_MODE` environment variable
set by the RoadRunner server for your plugin.

### Integrate with RoadRunner Logger

You can set the RoadRunner RPC address in your `.env` file (or use the default `tcp://127.0.0.1:6001`):

```
RR_RPC=tcp://127.0.0.1:6001
```

After that, you can use the logger in your Laravel application by specifying the `rr` channel:

```php
logger('rr')->info('This is an info message');
```
Comment on lines +413 to +415
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incorrect usage example – logger('rr') logs a message, not selects a channel

In Laravel the logger() helper treats the first argument as the message.
To obtain a logger for a specific channel you need:

-logger('rr')->info('This is an info message');
+logger()->channel('rr')->info('This is an info message');

or simply keep the Log::channel('rr') example below.

Please update to prevent confusion.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```php
logger('rr')->info('This is an info message');
```
🤖 Prompt for AI Agents
In README.md around lines 413 to 415, the example using logger('rr')->info('This
is an info message') is incorrect because the logger() helper treats the first
argument as the message, not as a channel selector. To fix this, replace the
example with the correct usage for logging to a specific channel, such as using
Log::channel('rr')->info('This is an info message'), or remove the incorrect
example and keep the existing Log::channel('rr') example to avoid confusion.


Or directly via the Log facade:

```php
use Illuminate\Support\Facades\Log;

Log::channel('rr')->error('An error occurred');
```

## Support

If you find this package helpful, please consider giving it a star on GitHub.
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"spiral/roadrunner-worker": "^3.0",
"temporal/sdk": "^2.0",
"internal/dload": "^1.1",
"spiral/grpc-client": "^1.0.0-rc1"
"spiral/grpc-client": "^1.0.0-rc1",
"hungthai1401/laravel-roadrunner-logger": "^1.0"
},
"require-dev": {
"laravel/framework": "^12.0",
Expand Down