@@ -22,17 +22,17 @@ protected function getSimpleExpectedLog(): Log
2222 {
2323 return (new TestPatternLog ())
2424 ->setLogFile (new PathLogFile (__DIR__ . '/../../data/simple.log ' ))
25- ->addEntry ((new Entry ())->setLevel (Level::INFO )->setTime (1 )
25+ ->addEntry ((new Entry ())->setLevel (Level::INFO )->setTime (1 )-> setPrefix ( " [01.01.1970 00:00:01] [Log/INFO] " )
2626 ->addLine (new Line (1 , "[01.01.1970 00:00:01] [Log/INFO] This is the first message containing information. " )))
27- ->addEntry ((new Entry ())->setLevel (Level::DEBUG )->setTime (2 )
27+ ->addEntry ((new Entry ())->setLevel (Level::DEBUG )->setTime (2 )-> setPrefix ( " [01.01.1970 00:00:02] [Log/DEBUG] " )
2828 ->addLine (new Line (2 , "[01.01.1970 00:00:02] [Log/DEBUG] This is the second message containing a debug information. " )))
29- ->addEntry ((new Entry ())->setLevel (Level::WARNING )->setTime (3 )
29+ ->addEntry ((new Entry ())->setLevel (Level::WARNING )->setTime (3 )-> setPrefix ( " [01.01.1970 00:00:03] [Log/WARN] " )
3030 ->addLine (new Line (3 , "[01.01.1970 00:00:03] [Log/WARN] This is the third message containing a warning information. " )))
31- ->addEntry ((new Entry ())->setLevel (Level::ERROR )->setTime (4 )
31+ ->addEntry ((new Entry ())->setLevel (Level::ERROR )->setTime (4 )-> setPrefix ( " [01.01.1970 00:00:04] [Log/ERROR] " )
3232 ->addLine (new Line (4 , "[01.01.1970 00:00:04] [Log/ERROR] This is the third message containing an error information. " ))
3333 ->addLine (new Line (5 , "This line continues the error entry to add even more information. " ))
3434 ->addLine (new Line (6 , "This line is also part of the error entry. " )))
35- ->addEntry ((new Entry ())->setLevel (Level::INFO )->setTime (5 )
35+ ->addEntry ((new Entry ())->setLevel (Level::INFO )->setTime (5 )-> setPrefix ( " [01.01.1970 00:00:05] [Log/INFO] " )
3636 ->addLine (new Line (7 , "[01.01.1970 00:00:05] [Log/INFO] This is the last message of the log. " )));
3737 }
3838
@@ -46,15 +46,14 @@ public function testParse(): void
4646 $ this ->assertEquals ($ this ->getSimpleExpectedLog (), $ log );
4747 }
4848
49-
5049 public function testParseWithCustomParser (): void
5150 {
5251 $ logFile = new PathLogFile (__DIR__ . '/../../data/simple.log ' );
5352 $ log = (new TestPatternLog ())->setLogFile ($ logFile );
5453
5554 $ patternParser = (new PatternParser ())
56- ->setPattern ('/\[([^\]]+)\] \[[^\/]+\/([^\]]+)\].*/ ' )
57- ->setMatches ([PatternParser::TIME , PatternParser::LEVEL ])
55+ ->setPattern ('/( \[([^\]]+)\] \[[^\/]+\/([^\]]+)\]) .*/ ' )
56+ ->setMatches ([PatternParser::PREFIX , PatternParser:: TIME , PatternParser::LEVEL ])
5857 ->setTimeFormat ('d.m.Y H:i:s ' );
5958 $ log ->parse ($ patternParser );
6059
0 commit comments