ILIAS  release_8 Revision v8.25
class.ilLoggingSetupConfig.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
6
8
10{
11 protected bool $enabled;
12
13 protected ?string $path_to_logfile;
14 protected ?string $path_to_errorlogfiles;
15 protected ?string $errorlog_dir;
16
17 public function __construct(
18 bool $enabled,
19 ?string $path_to_logfile,
20 ?string $errorlog_dir
21 ) {
22 if ($enabled && !$path_to_logfile) {
23 throw new \InvalidArgumentException(
24 "Expected a path to the logfile, if logging is enabled."
25 );
26 }
27 $this->enabled = $enabled;
28 $this->path_to_logfile = $this->normalizePath($path_to_logfile);
29 $this->errorlog_dir = $this->normalizePath($errorlog_dir);
30 }
31
32 protected function normalizePath(?string $p): ?string
33 {
34 if (!$p) {
35 return null;
36 }
37 $p = preg_replace("/\\\\/", "/", $p);
38 return preg_replace("%/+$%", "", $p);
39 }
40
41 public function isEnabled(): bool
42 {
43 return $this->enabled;
44 }
45
46 public function getPathToLogfile(): ?string
47 {
49 }
50
51 public function getErrorlogDir(): ?string
52 {
54 }
55}
__construct(bool $enabled, ?string $path_to_logfile, ?string $errorlog_dir)
A configuration for the setup.
Definition: Config.php:27