Skip to content

Commit 1f7fc14

Browse files
committed
env sets the valid environment(s)
If not set, any environment will be valid
1 parent 8edb52b commit 1f7fc14

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Add these lines to your `config/services.php`:
2727
'recipients' => 'email',
2828
'level' => Monolog\Logger::INFO,
2929
'propagate' => true,
30+
'env' => ['staging', 'production'],
3031
],
3132
```
3233

@@ -37,6 +38,7 @@ Here are the variables references:
3738
* `recipients`: Can either be 1 email address, or an array of email addresses.
3839
* `level`: Minimum level to take care. The default is `Monolog\Logger:INFO`.
3940
* `propagate`: When `false`, if a record is handled, it won't be propagated to other handlers.
41+
* `env`: Can either be 1 environment name (like `production`) or an array of environment name.
4042

4143
Then, add this line to Laravel's `config/app.php`, inside the `providers` array:
4244

src/MonobulletServiceProvider.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ public function boot()
1717
{
1818
parent::boot();
1919

20-
$monolog = Log::getMonolog();
21-
$monolog->pushHandler(new PushbulletHandler(
22-
config('services.monobullet.token'),
23-
config('services.monobullet.recipients'),
24-
config('services.monobullet.level', Logger::INFO),
25-
config('services.monobullet.propagate', true)
26-
));
20+
if (in_array(config('app.env'), (array) config('services.monobullet.env', config('app.env')))) {
21+
$monolog = Log::getMonolog();
22+
$monolog->pushHandler(new PushbulletHandler(
23+
config('services.monobullet.token'),
24+
config('services.monobullet.recipients'),
25+
config('services.monobullet.level', Logger::INFO),
26+
config('services.monobullet.propagate', true)
27+
));
28+
}
2729
}
2830

2931
/**

0 commit comments

Comments
 (0)