Passed
Push — master ( 368ea8...00a7e0 )
by Kris
02:37 queued 01:05
created

SyslogParser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 18
rs 9.9
cc 1
nc 1
nop 2
1
<?php declare(strict_types=1);
2
3
/** 
4
 *  ___                      _
5
 * | _ \ __ _  _ _  ___ ___ | | ___  __ _
6
 * |  _// _` || '_|(_-</ -_)| |/ _ \/ _` |
7
 * |_|  \__,_||_|  /__/\___||_|\___/\__, |
8
 *                                  |___/
9
 * 
10
 * (c) Kristuff <[email protected]>
11
 *
12
 * For the full copyright and license information, please view the LICENSE
13
 * file that was distributed with this source code.
14
 *
15
 * @version    0.2.0
16
 * @copyright  2017-2020 Kristuff
17
 */
18
19
namespace Kristuff\Parselog\Software;
20
21
use Kristuff\Parselog\Core\LogEntryFactoryInterface;
22
23
/**
24
 *  Aug 15 10:39:01 domain CRON[25038]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
25
 */
26
class SyslogParser extends SoftwareLogParser
27
{
28
    /**
29
     * Constructor
30
     * 
31
     * @access public
32
     * @param string                    $format    
33
     * @param LogEntryFactoryInterface  $factory        
34
     * 
35
     * @return void
36
     */
37
    public function __construct(string $format = null, LogEntryFactoryInterface $factory = null)
38
    {
39
        $this->software       = 'Syslog';
40
        $this->prettyName     = 'Syslog';
41
        
42
        $this->addFormat('default', '%t %h %s %m');
43
        $this->defaultFormat      = '%t %h %s %m';
44
        
45
        $this->addPath("/var/log/");
46
        $this->addFile("syslog");
47
        //todo
48
49
        $this->addColumn('%t',  'time',         'Date',     '(?P<time>(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{2} \d{2}:\d{2}:\d{2})');
50
        $this->addColumn('%h',  'hostaname',    'Hostname', '(?P<hostname>.+?)');
51
        $this->addColumn('%s',  'service',      'Service',  '(?P<service>(\S+|\[\d+\])):');
52
        $this->addColumn('%m',  'message',      'Message',  '(?P<message>.+)');
53
54
        parent::__construct($format, $factory);
55
    }
56
}