Skip to content

Conversation

@butonic
Copy link
Member

@butonic butonic commented Aug 10, 2016

To debug windows network drive issues we need traces. Unfortunately, installing xdebug is not always an option. being able to swith it on via a command line switch is a big win. We did it for 8.2 while debugging a problem. This PR brings the logging part to master.

The leave() and swallow() could be pulled up to the Common Storage or moved to the ILogger api. For now, having it in smb should suffice. We can move it to core if it turns out useful in other places.

cc @felixboehm @DeepDiver1975

@mention-bot
Copy link

@butonic, thanks for your PR! By analyzing the annotation information on this pull request, we identified @icewind1991, @blizzz, @jvillafanez and @Xenopathic to be potential reviewers

@butonic butonic added this to the 9.2 milestone Aug 10, 2016
$result = true;
} catch (ConnectException $e) {
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);
throw $this->leave(__FUNCTION__, new StorageNotAvailableException(
Copy link
Member

Choose a reason for hiding this comment

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

Can we leave the throw statement as is and add the leave() call right before is like this:

$this->leave(__FUNCTION__);
throw new StorageNotAvailableException($e->getMessage(), $e->getCode(), $e);

Copy link
Member Author

Choose a reason for hiding this comment

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

no, because these exceptions are sometimes swallowed, eg. by the availability wrapper: https://github.com/owncloud/core/blob/master/lib/private/Files/Storage/Wrapper/Availability.php#L53.

leave() detects an exception and also logs a stacktrace which is the most interesting thing when debugging this.

Copy link
Member

Choose a reason for hiding this comment

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

Then:

$e = new exception
This->leave(function, $e)
Throw $e

Copy link
Member Author

Choose a reason for hiding this comment

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

we could do that but it only adds an unnecessary variable.

Copy link
Member

Choose a reason for hiding this comment

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

and adds more structure to the code. 😉

@jvillafanez
Copy link
Member

reviewed

@butonic
Copy link
Member Author

butonic commented Aug 11, 2016

@jvillafanez @DeepDiver1975 thx for the quick review! I updated the PR accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

I'd also check that the 'password' key exists, so the log won't interfere with the normal flow. If somehow the 'password' key is missing, I guess the log below won't be shown and the expected exception won't be thrown.

Copy link
Member Author

Choose a reason for hiding this comment

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

empty does not log a warning when an arrey key is not defined: http://stackoverflow.com/questions/20531397/workaround-for-isset-array-key-exists-and-empty

Copy link
Member

Choose a reason for hiding this comment

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

I guess it's fine. I'd add a comment because it's confusing for me: I'd expect the code to explode trying to access to a missing index.

If there are no more pending changes let's go with this as it is. Don't bother to add a new commit just for adding a comment 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

empty() works fine for unset keys however there is kind of a false positive when checking with empty(): it will return true when checking an array key that has been set to 0 or "0". But I can live with that.

@butonic
Copy link
Member Author

butonic commented Aug 11, 2016

reviews are in. give me your 👍 pls

@jvillafanez @felixboehm @DeepDiver1975

@jvillafanez
Copy link
Member

👍

@butonic
Copy link
Member Author

butonic commented Aug 12, 2016

made @DeepDiver1975 happy, lets see if jenkins is still happy

@butonic
Copy link
Member Author

butonic commented Aug 12, 2016

needs backport to 9.1 and 9.0

@DeepDiver1975
Copy link
Member

@butonic scrutinizer is reporting 24 new issues - mind taking a look? THX

@DeepDiver1975
Copy link
Member

I'll kick jenkins

@butonic
Copy link
Member Author

butonic commented Aug 14, 2016

Scrutinizer does not know where to find the used exceptions. Dunno why he finds those problems now ... not an issue IMO.

@DeepDiver1975
Copy link
Member

👍

@DeepDiver1975 DeepDiver1975 merged commit b5bb06a into master Aug 14, 2016
@DeepDiver1975 DeepDiver1975 deleted the smb_tracing branch August 14, 2016 15:15
@lock
Copy link

lock bot commented Aug 5, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Aug 5, 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.

5 participants