Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added LogViewer as submodule + format a multi line log message into multiple log messages for file handler #8749

Merged
merged 5 commits into from Sep 22, 2015

Conversation

tsteur
Copy link
Member

@tsteur tsteur commented Sep 10, 2015

fixes #7239

Re formatting see #7239 (comment)

It's not a good idea to log multi-line messages instead we log one message for each line.

@tsteur tsteur added not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org. Needs Review PRs that need a code review labels Sep 10, 2015
@tsteur tsteur added this to the 2.15.0 milestone Sep 10, 2015
@tsteur tsteur changed the title Format a multi line log message into multiple log messages for file handler Added LogViewer as submodule + format a multi line log message into multiple log messages for file handler Sep 10, 2015
@tsteur
Copy link
Member Author

tsteur commented Sep 10, 2015

FYI: Will try to fix tests tmrw. Not sure why they fail but work in the LogViewer plugin itself

@diosmosis
Copy link
Member

Since this will close the issue, I will try to fix the build.

@diosmosis
Copy link
Member

The following changes will make LogTest.php pass:

diff --git a/plugins/Monolog/Formatter/LineMessageFormatter.php b/plugins/Monolog/Formatter/LineMessageFormatter.php
index 8224ff7..c9bff1e 100644
--- a/plugins/Monolog/Formatter/LineMessageFormatter.php
+++ b/plugins/Monolog/Formatter/LineMessageFormatter.php
@@ -40,7 +40,7 @@ class LineMessageFormatter implements FormatterInterface
         $class = isset($record['extra']['class']) ? $record['extra']['class'] : '';
         $date = $record['datetime']->format('Y-m-d H:i:s');

-        $message = $record['message'];
+        $message = trim($record['message']);

         if ($this->allowInlineLineBreaks) {
             $message  = str_replace("\n", "\n  ", $message); // intend lines
diff --git a/plugins/Monolog/tests/Integration/LogTest.php b/plugins/Monolog/tests/Integration/LogTest.php
index 97dc5e8..8de0250 100644
--- a/plugins/Monolog/tests/Integration/LogTest.php
+++ b/plugins/Monolog/tests/Integration/LogTest.php
@@ -201,6 +201,8 @@ class LogTest extends IntegrationTestCase
             $fileContents = file_get_contents(self::getLogFileLocation());
             $fileContents = $this->removePathsFromBacktrace($fileContents);

+            $expectedMessage = str_replace("\n ", "\n[Monolog]",$expectedMessage);
+
             $this->assertEquals($expectedMessage . "\n", $fileContents);
         } else if ($backend == 'database') {
             $queryLog = Db::isQueryLogEnabled();

& remove plugins/LogViewer/config/test.php.

The LogViewer tests seem to run against the 3.0 branch, so didn't go into those.

@tsteur
Copy link
Member Author

tsteur commented Sep 11, 2015

The LogViewer tests seem to run against the 3.0 branch, so didn't go into those.

That's not intended. Think I will remove the .travis.yml from LogViewer plugin once it is merged as a submodule as the tests should run with core already anyway. Does that make sense?

@diosmosis
Copy link
Member

I wasn't referring to travis. I tried to fix the LogViewer tests and noticed the API output for the system tests includes errors for the 3.0 branch. Did you run the tests initially against 3.0? I wasn't sure, so I didn't look further.

@tsteur
Copy link
Member Author

tsteur commented Sep 21, 2015

I get what you mean, yes that's expected. I created a sample log file that I configured to be used in tests via DI. The log file is simply a few lines extracted of my own log file. Will have a look at the tests

@tsteur
Copy link
Member Author

tsteur commented Sep 21, 2015

Tests are fixed. Failing UI tests are expected in http://builds-artifacts.piwik.org/piwik/piwik/7239/15524/

@mattab
Copy link
Member

mattab commented Sep 22, 2015

Wanted to merge this PR but noticed the AllTests build on MysqlI fails for some reason:

There were 2 errors:
1) Piwik\Plugins\LogViewer\tests\Integration\LogReaderFactoryTest::test_make_shouldMakeRequested_LogReader
Exception: Specified path to log file does not exist: /home/travis/build/piwik/piwik/tmp/logs/piwik.log
/home/travis/build/piwik/piwik/plugins/LogViewer/Log/Reader/File.php:27
/home/travis/build/piwik/piwik/plugins/LogViewer/LogReaderFactory.php:31
/home/travis/build/piwik/piwik/plugins/LogViewer/tests/Integration/LogReaderFactoryTest.php:73
2) Piwik\Plugins\LogViewer\tests\Integration\LogReaderFactoryTest::test_make_shouldBeAbleToDetectSourceAutomatically_IfOnlyOneReaderConfiguredAndNoneSpecified
Exception: Specified path to log file does not exist: /home/travis/build/piwik/piwik/tmp/logs/piwik.log
/home/travis/build/piwik/piwik/plugins/LogViewer/Log/Reader/File.php:27
/home/travis/build/piwik/piwik/plugins/LogViewer/LogReaderFactory.php:31
/home/travis/build/piwik/piwik/plugins/LogViewer/tests/Integration/LogReaderFactoryTest.php:92

@tsteur
Copy link
Member Author

tsteur commented Sep 22, 2015

Made a change that should fix this one. Will merge as soon as it passes

tsteur added a commit that referenced this pull request Sep 22, 2015
Added LogViewer as submodule + format a multi line log message into multiple log messages for file handler
@tsteur tsteur merged commit 01ebe2e into master Sep 22, 2015
@tsteur tsteur deleted the 7239 branch September 22, 2015 08:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review not-in-changelog For issues or pull requests that should not be included in our release changelog on matomo.org.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants