Completed
Push — master ( 40c839...4a6871 )
by Flo
05:59
created

DefaultWriter::write()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 7
nc 1
nop 3
1
<?php
2
3
namespace Faulancer\Log\Writer;
4
5
/**
6
 * Class DefaultWriter | DefaultWriter.php
7
 *
8
 * @package Faulancer\Log
9
 * @author  Florian Knapp <[email protected]>
10
 */
11
class DefaultWriter extends AbstractWriter
12
{
13
14
    /**
15
     * Write default log format
16
     *
17
     * @inheritdoc
18
     * @return int|bool
19
     */
20
    public function write(string $logfile, string $message, string $level)
21
    {
22
        $columns = [
23
            (new \DateTime())->format('d.m.Y H:i:s'),
24
            strtoupper($level),
25
            $message
26
        ];
27
28
        $messageString  = implode(' | ', $columns) . "\r\n";
29
30
        return file_put_contents($logfile, $messageString, FILE_APPEND);
31
    }
32
33
}