Skip to content

Conditional logging#15965

Merged
DeepDiver1975 merged 2 commits into
masterfrom
conditional-logging
May 19, 2015
Merged

Conditional logging#15965
DeepDiver1975 merged 2 commits into
masterfrom
conditional-logging

Conversation

@MorrisJobke

Copy link
Copy Markdown
Contributor

Log condition for log level increase based on conditions. Once one of these conditions is met, the required log level is set to debug. This allows to debug specific requests, users or apps

Supported conditions (setting log_condition in config.php):
- secret: if a request parameter with the name log_secret is set to this value the condition is met
- users: if the current request is done by one of the specified users, this condition is met
- apps: if the log message is invoked by one of the specified apps, this condition is met

This would be really helpful to debug bigger installations where enabling a higher log level isn't a option because of the huge amount of log messages. cc @felixboehm @butonic

cc @nickvergessen @PVince81 @rullzer @Xenopathic @Raydiation @DeepDiver1975

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

I used the internal \OC\SystemConfig here to not run into cyclic conditions here. As this is the logger I want to reduce the needed bootstrapped system to a minimum. Otherwise it could be possible to no able to log, because the injected object couldn't be build. The system config was also required previously. And as this is an internal class I think this is not a problem. Opinions?

@felixboehm

Copy link
Copy Markdown
Contributor

Awesome stuff, logfiles often are so big and this really helps

@karlitschek

Copy link
Copy Markdown
Contributor

nice idea 👍

@DeepDiver1975 DeepDiver1975 added this to the 8.1-current milestone May 4, 2015
@DeepDiver1975
DeepDiver1975 force-pushed the conditional-logging branch from 753c2db to 023734c Compare May 4, 2015 07:15
@DeepDiver1975

Copy link
Copy Markdown
Member

rebased after merge of #15958

@DeepDiver1975

Copy link
Copy Markdown
Member

@MorrisJobke unit tests are broken

Test\Logger::testInterpolation
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
-    0 => '1 {Message {nothing} Bob Bar a}'
 )

/var/jenkins/workspace/pull-request-analyser-ng-simple@3/label/SLAVE/tests/lib/logger.php:32

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

I added a unit test for the app condition.

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

@LukasReschke @nickvergessen @rullzer @Xenopathic Do you want to review?

@LukasReschke

Copy link
Copy Markdown
Contributor

"want"

Comment thread config/config.sample.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shared_secret?

* remove duplicate code from child classes
@MorrisJobke
MorrisJobke force-pushed the conditional-logging branch from 0ad6ba7 to 0d3fea2 Compare May 8, 2015 13:14
@MorrisJobke

Copy link
Copy Markdown
Contributor Author

Do we want to use a header or not?

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

BTW: all the other comments are addressed.

Comment thread config/config.sample.php Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Erm? 🙈

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now doc and content is not the same anymore 🙈

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ... forgot that one

 * Log condition for log level increase based on conditions. Once one of these
   conditions is met, the required log level is set to debug. This allows to
   debug specific requests, users or apps

 * Supported conditions (setting `log_condition` in `config.php`):
    - `shared_secret`: if a request parameter with the name `log_secret` is set to
                this value the condition is met
    - `users`:  if the current request is done by one of the specified users,
                this condition is met
    - `apps`:   if the log message is invoked by one of the specified apps,
                this condition is met
 * fix unit test and add app log condition test
@MorrisJobke
MorrisJobke force-pushed the conditional-logging branch from 0d3fea2 to e79c255 Compare May 8, 2015 14:01
@scrutinizer-notifier

Copy link
Copy Markdown

A new inspection was created.

@ghost

ghost commented May 18, 2015

Copy link
Copy Markdown

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/12374/
🚀 Test PASSed.🚀
chuck

@MorrisJobke

Copy link
Copy Markdown
Contributor Author

@LukasReschke @nickvergessen @rullzer @Xenopathic Ready for review :)

@rullzer

rullzer commented May 19, 2015

Copy link
Copy Markdown
Contributor

Working very nice!
I would like to see a header as well (maybe different PR, if it is to much work since this should get in). So debugging the OCS API etc becomes a bit easier.

As mentioned on IRC the call_user_func stuff makes me cry. But also that should be addressed in another PR.

👍 !

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this removed? @MorrisJobke THX

@DeepDiver1975

Copy link
Copy Markdown
Member

👍

DeepDiver1975 added a commit that referenced this pull request May 19, 2015
@DeepDiver1975
DeepDiver1975 merged commit a52afb0 into master May 19, 2015
@DeepDiver1975
DeepDiver1975 deleted the conditional-logging branch May 19, 2015 10:00
mmattel pushed a commit to mmattel/core that referenced this pull request May 22, 2015
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants