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

Conditional logging #15965

Merged
merged 2 commits into from May 19, 2015
Merged

Conditional logging #15965

merged 2 commits into from May 19, 2015

Conversation

MorrisJobke
Copy link
Contributor

@MorrisJobke MorrisJobke commented Apr 30, 2015

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
Contributor Author

MorrisJobke commented Apr 30, 2015

@MorrisJobke
Copy link
Contributor Author

MorrisJobke commented Apr 30, 2015

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
Contributor

felixboehm commented Apr 30, 2015

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

@karlitschek
Copy link
Contributor

karlitschek commented Apr 30, 2015

nice idea 👍

@DeepDiver1975 DeepDiver1975 added this to the 8.1-current milestone May 4, 2015
@DeepDiver1975
Copy link
Member

DeepDiver1975 commented May 4, 2015

rebased after merge of #15958

@DeepDiver1975
Copy link
Member

DeepDiver1975 commented May 4, 2015

@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
Contributor Author

MorrisJobke commented May 4, 2015

I added a unit test for the app condition.

@MorrisJobke
Copy link
Contributor Author

MorrisJobke commented May 8, 2015

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

@LukasReschke
Copy link
Member

LukasReschke commented May 8, 2015

"want"

* debug specific requests, users or apps
*
* Supported conditions:
* - ``secret``: if a request parameter with the name `log_secret` is set to
Copy link
Member

@LukasReschke LukasReschke May 8, 2015

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
Copy link
Contributor Author

MorrisJobke commented May 8, 2015

Do we want to use a header or not?

@MorrisJobke
Copy link
Contributor Author

MorrisJobke commented May 8, 2015

BTW: all the other comments are addressed.

* Defaults to an empty array.
*/
'log.condition' => [
'secret' => '57b58edb6637fe3059b3595cf9c41b9',
Copy link
Member

@LukasReschke LukasReschke May 8, 2015

Choose a reason for hiding this comment

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

Erm? 🙈

Copy link
Member

@LukasReschke LukasReschke May 8, 2015

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
Contributor Author

@MorrisJobke MorrisJobke May 8, 2015

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
@scrutinizer-notifier
Copy link

scrutinizer-notifier commented May 8, 2015

A new inspection was created.

@ghost
Copy link

ghost commented May 18, 2015

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
Contributor Author

MorrisJobke commented May 18, 2015

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

@rullzer
Copy link
Contributor

rullzer commented May 19, 2015

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.

👍 !

@@ -39,10 +39,7 @@ public static function init() {
* @param int $level
*/
public static function write($app, $message, $level) {
$minLevel = min(OC_Config::getValue("loglevel", OC_Log::WARN), OC_Log::ERROR);
if ($level >= $minLevel) {
Copy link
Member

@DeepDiver1975 DeepDiver1975 May 19, 2015

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
Member

DeepDiver1975 commented May 19, 2015

👍

DeepDiver1975 added a commit that referenced this issue May 19, 2015
@DeepDiver1975 DeepDiver1975 merged commit a52afb0 into master May 19, 2015
1 check passed
@DeepDiver1975 DeepDiver1975 deleted the conditional-logging branch May 19, 2015
mmattel pushed a commit to mmattel/core that referenced this issue 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.

None yet

8 participants