You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With topics_level you can set PHP Attribute(Annotation) to controller function
69
+
### 🏷️ Topic-Based Logging
75
70
76
-
and change the topic id base on this attributes
71
+
You can assign a **PHP Attribute (Annotation)** to controller methods, command handlers, or job handlers, enabling topic-based logging. The package will use the first detected attribute to determine the topic for logging messages.
77
72
78
-
Note: this package will only process first attribute
73
+
#### 💡 Example:
79
74
80
-
Example:
75
+
**📌 Controller Method:**
81
76
82
77
```php
83
78
namespace App\Http\Controllers\NewWeb;
@@ -91,48 +86,72 @@ class HomeController extends Controller
91
86
#[EmergencyAttribute]
92
87
public function index(Request $request)
93
88
{
94
-
//
89
+
// Your logic here
95
90
}
96
91
}
97
92
```
98
93
99
-
You can customize token, chat_id and topic_id in run time
94
+
**⚡ Command or Job Handler:**
100
95
101
96
```php
97
+
namespace App\Jobs;
98
+
99
+
use Illuminate\Bus\Queueable;
100
+
use Illuminate\Contracts\Queue\ShouldBeQueued;
101
+
use Illuminate\Foundation\Bus\Dispatchable;
102
+
use TheCoder\MonologTelegram\Attributes\CriticalAttribute;
103
+
104
+
class ProcessData implements ShouldBeQueued
105
+
{
106
+
use Dispatchable, Queueable;
102
107
108
+
#[CriticalAttribute]
109
+
public function handle()
110
+
{
111
+
// Job processing logic
112
+
}
113
+
}
114
+
```
115
+
116
+
### 🔄 Customizing Log Settings at Runtime
117
+
118
+
You can dynamically set the bot token, chat ID, and topic ID while logging:
119
+
120
+
```php
103
121
logger('message', [
104
-
'token' => 'your bot token',
105
-
'chat_id' => 'your chat id',
106
-
'topic_id' => 'your topic id'
122
+
'token' => 'your_bot_token',
123
+
'chat_id' => 'your_chat_id',
124
+
'topic_id' => 'your_topic_id'
107
125
]);
108
-
109
126
```
110
127
111
-
Add the following variables to your .env file.
128
+
## 📜 Environment Variables
129
+
130
+
Ensure the following variables are set in your `.env` file:
112
131
113
-
```dotenv
132
+
```ini
114
133
LOG_TELEGRAM_BOT_TOKEN=
115
134
LOG_TELEGRAM_CHAT_ID=
116
135
117
-
# If chat groups are used instead of telegram channels,
118
-
# and the ability to set topics on groups is enabled,
119
-
# this configuration can be utilized.
136
+
# 🏷️ If using chat groups with topic support, define the topic ID
0 commit comments