-
Notifications
You must be signed in to change notification settings - Fork 3
/
File.php
46 lines (39 loc) · 1.08 KB
/
File.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* This file is part of the Apix Project.
*
* (c) Franck Cassedanne <franck at ouarz.net>
*
* @license http://opensource.org/licenses/BSD-3-Clause New BSD License
*/
namespace Apix\Log\Logger;
use Psr\Log\InvalidArgumentException;
/**
* Minimalist file based PSR-3 logger relying on PHP's error_log().
*
* @author Franck Cassedanne <franck at ouarz.net>
*/
class File extends ErrorLog
{
/**
* Constructor.
*
* @param string $file The file to append to.
* @throws InvalidArgumentException If the file cannot be created or written.
*/
public function __construct($file)
{
if (null === $file || !file_exists($file) && !touch($file)) {
throw new InvalidArgumentException(
sprintf('Log file "%s" cannot be created', $file), 1
);
}
if (!is_writable($file)) {
throw new InvalidArgumentException(
sprintf('Log file "%s" is not writable', $file), 2
);
}
$this->destination = $file;
$this->type = static::FILE;
}
}