Skip to content
Merged
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
87 changes: 86 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,81 @@ system environment variables; do not enable if sensitive information such as pas
$logger = new Logger('application_name', 'environment_name', $transport, true);
```


### **Configuration Settings**
- This allow users to override default settings of the logger (Masking Request Variables, Session, Cookie or Updating connection properties to different Transports etc.)
- **Note** - For the `Whitelist/Blackist` setting. Anything `falsy` (`null`, `false`, `array()` etc. - Refer to php [empty](https://www.php.net/manual/en/function.empty.php) function checking) will be considered as `Do Not Track` - No variable data will be processed.

#### Logger Level
```php
$config = array(
'CaptureServerVariables' => false,
'CaptureServerVariablesWhitelist' => '*',
'CaptureServerVariablesBlacklist' => 'REMOTE_ADDR,SERVER_ADDR',
...
);

$logger = new Logger('application_name', 'environment_name', $transport, true, $config);
```

#### Transport Level
- This applies to all the transports `(ExecTransport, CurlTransport, AgentTransport, AgentSocketTransport)`
```php
$config = array(
'CaptureServerVariables' => false,
'CaptureServerVariablesWhitelist' => '*',
'CaptureServerVariablesBlacklist' => 'REMOTE_ADDR,SERVER_ADDR',
...
);

$transport = new ExecTransport($apiKey, [
'config' => $config
]);
```
### Available Options:
#### Server Variables
- `CaptureServerVariables` - `Boolean` - Capture `$_SERVER` variables
- `CaptureServerVariablesWhitelist` - `Array` or `Comma-delimited string` - Whitelist `$_SERVER` attributes
- `CaptureServerVariablesBlacklist` - `Array` or `Comma-delimited string` - Mask `$_SERVER` attributes (e.g. `attribute => 'X-MASKED-X'`)
#### Get Variables
- `CaptureGetVariables` - `Boolean` - Capture `$_GET` variables
- `CaptureGetVariablesWhitelist` - `Array` or `Comma-delimited string` - Whitelist `$_GET` attributes
- `CaptureGetVariablesBlacklist` - `Array` or `Comma-delimited string` - Mask `$_GET` attributes (e.g. `attribute => 'X-MASKED-X'`)
#### Post Variables
- `CapturePostVariables` - `Boolean` - Capture `$_POST` variables
- `CapturePostVariablesWhitelist` - `Array` or `Comma-delimited string` - Whitelist `$_POST` attributes
- `CapturePostVariablesBlacklist` - `Array` or `Comma-delimited string` - Mask `$_POST` attributes (e.g. `attribute => 'X-MASKED-X'`)
#### Session Variables
- `CaptureSessionVariables` - `Boolean` - Capture `$_SESSION` variables
- `CaptureSessionVariablesWhitelist` - `Array` or `Comma-delimited string` - Whitelist `$_SESSION` attributes
- `CaptureSessionVariablesBlacklist` - `Array` or `Comma-delimited string` - Mask `$_SESSION` attributes (e.g. `attribute => 'X-MASKED-X'`)
#### Error Headers
- `CaptureErrorHeaders` - `Boolean` - Capture `HEADER` attributes available in `$_SERVER` variable
- `CaptureErrorHeadersWhitelist` - `Array` or `Comma-delimited string` - Whitelist `HEADER` attributes in `$_SERVER` variable
- `CaptureErrorHeadersBlacklist` - `Array` or `Comma-delimited string` - Mask `HEADER` attributes in `$_SERVER` variable (e.g. `attribute => 'X-MASKED-X'`)
#### Error Cookies
- `CaptureErrorCookies` - `Boolean` - Capture `$_COOKIE` variables
- `CaptureErrorCookiesWhitelist` - `Array` or `Comma-delimited string` - Whitelist `$_COOKIE` attributes
- `CaptureErrorCookiesBlacklist` - `Array` or `Comma-delimited string` - Mask `$_COOKIE` attributes
#### Capture Raw Post Data
- `CaptureRawPostData` - `Boolean` - Capture `php://input` stream data `(e.g. file_get_contents("php://input"))`
#### Debug Settings
- `Debug` - `Boolean` - Enable DEBUG in the logger
- `DebugLogPath` - `String` - A qualified path for the log file produced during debug or error
#### Agent Transport Settings
- `Protocol` - `String` - Protocol can be `tcp` or `udp`
- `Host` - `String` - Server Hostname
- `Port` - `Numeric` - Port
- `SocketTimeoutConnect` - `Numeric` - Connection Request Timeout
- `SocketTimeoutWrite` - `Numeric` - Connection Write Timeout
- `SocketMaxConnectAttempts` - `Numeric` - Connection Attempts
#### Agent Socket Transport Settings
- `DomainSocketPath` - `String` - Stackify Agent unix socket path
#### API or Curl Exec Socket Transport Settings
- `ApiBaseUrl` - `String` - Stackify API base url
- `ApiCallLogsEndpoint` - `String` - Stackify API Call Logs endpoint
- `ApiMaxTimeout` - `Numeric` - Stackify API Call Max Timeout
- `ApiVersionHeader` - `String` - Stackify API Version Header

#### Troubleshooting

If transport does not work, try looking into ```vendor\stackify\logger\src\Stackify\debug\log.log``` file (if it is available for writing). Errors are also written to global PHP [error_log](http://php.net/manual/en/errorfunc.configuration.php#ini.error-log).
Expand All @@ -71,6 +145,17 @@ Note that ExecTransport does not produce any errors at all, but you can switch i
$transport = new ExecTransport($apiKey, ['debug' => true]);
```

You can set it also on the `Logger` level. Setting the `Debug` and `DebugLogPath`

```php
$config = array(
'DebugLogPath' => '/path/to/log.log',
'Debug' => true
);

$logger = new Logger('application_name', 'environment_name', $transport, true, $config);
```

## License

Copyright 2019 Stackify, LLC.
Expand Down
15 changes: 14 additions & 1 deletion src/Stackify/Log/Entities/Api/StackifyError.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Stackify\Log\Entities\Api;

use Stackify\Log\Transport\Config\Agent;

class StackifyError
{
/**
Expand Down Expand Up @@ -50,9 +52,20 @@ public function __construct($appName, $environmentName, $logServerVariables = fa
}
}

/**
* Get server environment variables
*
* @return array
*/
private function getEnvironmentVariables()
{
return isset($_SERVER) ? WebRequestDetail::getRequestMap($_SERVER) : null;
$agentConfig = Agent::getInstance();
if ($agentConfig) {
return isset($_SERVER) && $agentConfig->getCaptureServerVariables()
? WebRequestDetail::getRequestMap($_SERVER, $agentConfig->getCaptureServerVariablesBlacklist(), $agentConfig->getCaptureServerVariablesWhitelist())
: null;
}
return isset($_SERVER) ? WebRequestDetail::getRequestMap($_SERVER, null, array('*')) : null;
}

}
Loading