|
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.7.2 |
|
16
|
|
|
* @copyright 2017-2021 Kristuff |
|
17
|
|
|
*/ |
|
18
|
|
|
|
|
19
|
|
|
namespace Kristuff\Parselog\Software; |
|
20
|
|
|
|
|
21
|
|
|
use Kristuff\Parselog\Core\LogEntryFactoryInterface; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* https://mariadb.com/kb/en/error-log/ |
|
25
|
|
|
* |
|
26
|
|
|
* Until MariaDB 10.1.4, the format consisted of the date (yymmdd) and time, followed by the type of error (Note, Warning or Error) and the error message, for example: |
|
27
|
|
|
* 160615 16:53:08 [Note] InnoDB: The InnoDB memory heap is disabled |
|
28
|
|
|
* |
|
29
|
|
|
* From MariaDB 10.1.5, the date format has been extended to yyyy-mm-dd, and the thread ID has been added, for example: |
|
30
|
|
|
* 2016-06-15 16:53:33 139651251140544 [Note] InnoDB: The InnoDB memory heap is disabled |
|
31
|
|
|
* |
|
32
|
|
|
* |
|
33
|
|
|
* 2021-10-15 5:04:02 3163 [Warning] Aborted connection 3163 to db: 'xxx' user: 'xxx' host: 'localhost' (Got timeout reading communication packets) |
|
34
|
|
|
*/ |
|
35
|
|
|
class MariadbErrorLogParser extends SoftwareLogParser |
|
36
|
|
|
{ |
|
37
|
|
|
/** |
|
38
|
|
|
* Constructor |
|
39
|
|
|
* |
|
40
|
|
|
* @access public |
|
41
|
|
|
* @param string $format |
|
42
|
|
|
* @param LogEntryFactoryInterface $factory |
|
43
|
|
|
* |
|
44
|
|
|
* @return void |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct(string $format = null, LogEntryFactoryInterface $factory = null) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->software = 'MariaDB'; |
|
49
|
|
|
$this->prettyName = 'MariaDB Error'; |
|
50
|
|
|
|
|
51
|
|
|
$this->addFormat('default', '%t %i %l %m'); |
|
52
|
|
|
$this->defaultFormat = '%t %i %l %m'; |
|
53
|
|
|
|
|
54
|
|
|
$this->addPath("/var/log/mysql/"); |
|
55
|
|
|
$this->addFile("error.log"); |
|
56
|
|
|
|
|
57
|
|
|
$this->addPattern('%t', '(?P<time>[0-9\-]+\s+[0-9:]+)'); |
|
58
|
|
|
$this->addPattern('%i', '(?P<tid>\d+)'); |
|
59
|
|
|
$this->addPattern('%l', '\[(?P<level>.+?)\]'); |
|
60
|
|
|
$this->addPattern('%m', '(?P<message>.+)'); |
|
61
|
|
|
|
|
62
|
|
|
parent::__construct($format, $factory); |
|
63
|
|
|
} |
|
64
|
|
|
} |