PluginProbe
authLdap / 3.0.3
authLdap v3.0.3
trunk 2.5.3 2.5.3-RC3 2.5.4 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4
authldap / src / Logger.php

Logger.php in authLdap 3.0.3, at src/Logger.php

42 lines 640 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace Org_Heigl\AuthLdap;
6
7 final class Logger implements LoggerInterface
8 {
9 private $debug;
10
11 /**
12 * @var false|resource
13 */
14 private $fh = false;
15
16 public function __construct(bool $debug = false)
17 {
18 $this->debug = $debug;
19 // $this->fh = fopen('php://stderr', 'w');
20 }
21 public function log(string $message): void
22 {
23 if (! $this->debug) {
24 return;
25 }
26
27 if ($this->fh !== false) {
28 fwrite($this->fh, '[AuthLDAP] ' . $message . PHP_EOL);
29 }
30 error_log('[AuthLDAP] ' . $message, 0);
31 }
32
33 public function __destruct()
34 {
35 if ($this->fh === false) {
36 return;
37 }
38
39 fclose($this->fh);
40 }
41 }
42