| Conditions | 3 |
| Paths | 3 |
| Total Lines | 26 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | public function create($service, array $params = []) |
||
| 19 | { |
||
| 20 | if (!empty($params)) { |
||
| 21 | throw new Exception('AuditFactory does not support passing params.'); |
||
| 22 | } |
||
| 23 | |||
| 24 | $obj = null; |
||
|
|
|||
| 25 | switch ($service) { |
||
| 26 | case 'AuditLogger': |
||
| 27 | $log = new Logger('audit'); |
||
| 28 | $syslog = new SyslogHandler('SilverStripe_audit', LOG_AUTH, Logger::DEBUG); |
||
| 29 | $syslog->pushProcessor(new WebProcessor($_SERVER, [ |
||
| 30 | 'url' => 'REQUEST_URI', |
||
| 31 | 'http_method' => 'REQUEST_METHOD', |
||
| 32 | 'server' => 'SERVER_NAME', |
||
| 33 | 'referrer' => 'HTTP_REFERER', |
||
| 34 | ])); |
||
| 35 | |||
| 36 | $syslog->pushProcessor(new RealIPProcessor()); |
||
| 37 | $formatter = new LineFormatter("%level_name%: %message% %context% %extra%"); |
||
| 38 | $syslog->setFormatter($formatter); |
||
| 39 | $log->pushHandler($syslog); |
||
| 40 | |||
| 41 | return $log; |
||
| 42 | default: |
||
| 43 | throw new Exception(sprintf("AuditFactory does not support creation of '%s'.", $service)); |
||
| 44 | } |
||
| 47 |