Skip to content

Commit bcedefc

Browse files
committed
RT-1844 - adding in logServerVariables toggle (defaults to disabled)
1 parent 6d4d11a commit bcedefc

File tree

4 files changed

+40
-10
lines changed

4 files changed

+40
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
vendor
22
composer.lock
3+
.idea

README.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,27 @@ monolog:
6666
6767
#### Optional Configuration
6868
69-
<b>Proxy</b>
69+
**Proxy**
7070
- ExecTransport supports data delivery through proxy. Specify proxy using [libcurl format](http://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html): <[protocol://][user:password@]proxyhost[:port]>
7171
```php
7272
$transport = new ExecTransport($apiKey, ['proxy' => 'https://55.88.22.11:3128']);
7373
```
7474

75-
<b>Curl path</b>
75+
**Curl path**
7676
- It can be useful to specify ```curl``` destination path for ExecTransport. This option is set to 'curl' by default.
7777
```php
7878
$transport = new ExecTransport($apiKey, ['curlPath' => '/usr/bin/curl']);
7979
```
8080

81+
**Log Server Environment Variables**
82+
- Server environment variables can be added to error log message metadata. **Note:** This will log all
83+
system environment variables; do not enable if sensitive information such as passwords or keys are stored this way.
84+
85+
```php
86+
$handler = new StackifyHandler('application_name', 'environment_name', $transport, true);
87+
```
88+
89+
8190
### CurlTransport
8291

8392
CurlTransport does not require a Stackify agent to be installed and it also sends data directly to Stackify services. It collects log entries in a single batch and sends data using native [PHP cURL](http://php.net/manual/en/book.curl.php) functions. This way is a blocking one, so it should not be used on production environments. To configure CurlTransport you need to pass environment name and API key (license key):
@@ -111,12 +120,20 @@ monolog:
111120
112121
#### Optional Configuration
113122
114-
<b>Proxy</b>
123+
**Proxy**
115124
- CurlTransport supports data delivery through proxy. Specify proxy using [libcurl format](http://curl.haxx.se/libcurl/c/CURLOPT_PROXY.html): <[protocol://][user:password@]proxyhost[:port]>
116125
```php
117126
$transport = new CurlTransport($apiKey, ['proxy' => 'https://55.88.22.11:3128']);
118127
```
119128

129+
**Log Server Environment Variables**
130+
- Server environment variables can be added to error log message metadata. **Note:** This will log all
131+
system environment variables; do not enable if sensitive information such as passwords or keys are stored this way.
132+
133+
```php
134+
$handler = new StackifyHandler('application_name', 'environment_name', $transport, true);
135+
```
136+
120137
### AgentTransport
121138

122139
AgentTransport does not require additional configuration in your PHP code because all data is passed to the [Stackify agent](https://stackify.screenstepslive.com/s/3095/m/7787/l/119709-installation-for-linux). The agent must be installed on the same machine. Local TCP socket on port 10515 is used, so performance of your application is affected minimally.
@@ -126,7 +143,7 @@ PHP:
126143
use Monolog\Logger;
127144
use Stackify\Log\Monolog\Handler as StackifyHandler;
128145

129-
$handler = new StackifyHandler('application_name');
146+
$handler = new StackifyHandler('application_name', 'environment_name');
130147
$logger = new Logger('logger');
131148
$logger->pushHandler($handler);
132149
```
@@ -136,7 +153,7 @@ Symfony:
136153
services:
137154
stackify_handler:
138155
class: "Stackify\\Log\\Monolog\\Handler"
139-
arguments: ["application_name"]
156+
arguments: ["application_name", "environment_name"]
140157
monolog:
141158
handlers:
142159
stackify:
@@ -146,6 +163,16 @@ monolog:
146163
147164
You will need to enable the TCP listener by checking the "PHP App Logs (Agent Log Collector)" in the server settings page in Stackify. See [Log Collectors Page](http://docs.stackify.com/m/7787/l/302705-log-collectors) for more details.
148165
166+
#### Optional Settings
167+
168+
**Log Server Environment Variables**
169+
- Server environment variables can be added to error log message metadata. **Note:** This will log all
170+
system environment variables; do not enable if sensitive information such as passwords or keys are stored this way.
171+
172+
```php
173+
$handler = new StackifyHandler('application_name', 'environment_name', null, true);
174+
```
175+
149176
## Notes
150177

151178
To get more error details pass Exception objects to the logger if available:
@@ -167,7 +194,7 @@ $transport = new ExecTransport($apiKey, ['debug' => true]);
167194

168195
## License
169196

170-
Copyright 2015 Stackify, LLC.
197+
Copyright 2018 Stackify, LLC.
171198

172199
Licensed under the Apache License, Version 2.0 (the "License");
173200
you may not use this file except in compliance with the License.

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
"license": "Apache-2.0",
88
"require": {
99
"php": "^7.0",
10-
"stackify/logger": "~1.0",
10+
"stackify/logger": "~1.1",
1111
"monolog/monolog": "~2.0"
1212
},
1313
"autoload": {
1414
"psr-4": {
1515
"Stackify\\Log\\Monolog\\": "src/Stackify/Log/Monolog"
1616
}
17-
}
17+
},
18+
"minimum-stability": "dev",
19+
"prefer-stable": true
1820
}

src/Stackify/Log/Monolog/Handler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ class Handler extends AbstractHandler
1717
*/
1818
private $transport;
1919

20-
public function __construct($appName, $environmentName = null, TransportInterface $transport = null, $level = Logger::DEBUG, $bubble = true)
20+
public function __construct($appName, $environmentName = null, TransportInterface $transport = null, $logServerVariables = false, $level = Logger::DEBUG, $bubble = true)
2121
{
2222
parent::__construct($level, $bubble);
23-
$messageBuilder = new MessageBuilder('Stackify Monolog v.2.0', $appName, $environmentName);
23+
$messageBuilder = new MessageBuilder('Stackify Monolog v.2.0', $appName, $environmentName, $logServerVariables);
2424
if (null === $transport) {
2525
$transport = new AgentTransport();
2626
}

0 commit comments

Comments
 (0)