Skip to content

Logfile download - #12988

Merged
MorrisJobke merged 1 commit into
masterfrom
logfile_download
Jan 8, 2015
Merged

MorrisJobke merged 1 commit into
masterfrom
logfile_download

Conversation

@georgehrke

Copy link
Copy Markdown
Contributor

implements / fixes #12731

TODO:

  • add unit test
  • add warning if log file is bigger than 100MB

@georgehrke

Copy link
Copy Markdown
Contributor Author

please review @MorrisJobke @LukasReschke

@karlitschek

Copy link
Copy Markdown
Contributor

@DeepDiver1975 @PVince81 what do you the think?

Comment thread settings/admin.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.

This won't work if the logger isn't of the class OC_Log_Owncloud. Is this the intended way to work? I will test this with other log implementations and how it behaves nowadays

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.

This will not work in case the log file is redirected to syslog - has to be handled as well.

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.

the whole log viewer in the admin settings only works with OC_Log_OwnCloud. (see the lines above the one I added). Do we want to change this behaviour?

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.

This will not work in case the log file is redirected to syslog

How are logs from syslog handled right now in the admin settings?

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.

They simply don't work. You get an empty response from OC_Log_Owncloud (as there is nothing written there) Maybe add a check and hide the section if something different is setup for ownCloud

@DeepDiver1975

Copy link
Copy Markdown
Contributor

and squash please - thx

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.

The type is already enforced by the type annotation :-)

@param int $level will enforce that the type is an int or set the value to 0.

Btw. VERY cool that you use the AppFramework. Kudos for that!

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.

Newline at EoF

@DeepDiver1975 DeepDiver1975 added this to the 8.0-current milestone Dec 22, 2014
@karlitschek

Copy link
Copy Markdown
Contributor

👍

@DeepDiver1975

Copy link
Copy Markdown
Contributor

@georgehrke can we get some momentum on this? THX

@georgehrke

Copy link
Copy Markdown
Contributor Author

@georgehrke can we get some momentum on this? THX

I will squash, add the test for the private method and add some kind of readfile response asap.

About the syslog problem:
I don't see a way to read the syslog from php. (except we want to parse the server/syslog config and try to read some files from /var/log, but that's something at least I don't feel comfortable with ;) )

@DeepDiver1975

Copy link
Copy Markdown
Contributor

Thanks Georg. Regarding syslog: we shall not allow download in this case - as a result we shall not offer this in the ui.

@karlitschek

Copy link
Copy Markdown
Contributor

thanks @georgehrke i agree with @DeepDiver1975 downloading syslog makes no sense

@karlitschek

Copy link
Copy Markdown
Contributor

@georgehrke can you look into that?

@georgehrke

Copy link
Copy Markdown
Contributor Author

@karlitschek Yes, will push my changes tomorrow

@karlitschek

Copy link
Copy Markdown
Contributor

cool. You like last minute changes, right? ;-)

@georgehrke

Copy link
Copy Markdown
Contributor Author
  • hide logs and log file download if logmode is not own cloud
  • add test for getFilenameForDownload

concerning the Response template:
The render method is supposed to return the output as string (which would require us to load the whole logfile into memory). Using readfile inside render and just returning an empty string won't work because it will cause 'headers already sent' errors. cc @Raydiation
see

$output = $response->render();

So I'd vote to stay with readfile inside the LogSettingsController for now.

@MorrisJobke

Copy link
Copy Markdown
Contributor

👍 fine from my side

@MorrisJobke

Copy link
Copy Markdown
Contributor

Jenkins PR is in #13075

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.

You can inject OCP\ITimeFactory and call $factory->getTime() to be able to test it instead of using time() directly

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.

needed? Please kill this - we shall use http status codes if necessary

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.

it's checked for in the js, but we can remove that check

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.

THe JS part can also rely on the HTTP code (even jQuery support two different callbacks for success and failure ;))

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.

Also here pretty sure that this is not required at all

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.

Lol - @DeepDiver1975 was faster while I was reviewing ;-)

add logSettingsController

add download logfile button

move getEntries to LogSettingsController

move set log level to logsettingscontroller.php

add warning if logfile is bigger than 100MB

add unit test for set log level

fix typecasting, add new line at EoF

show log and logfile download only if log_type is set to owncloud

add unit test for getFilenameForDownload
@ghost

ghost commented Jan 7, 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/6013/
👍 Test PASSed. 👍

@scrutinizer-notifier

Copy link
Copy Markdown

The inspection completed: 10 new issues, 17 updated code elements

@MorrisJobke

Copy link
Copy Markdown
Contributor

👍 still works

@karlitschek

Copy link
Copy Markdown
Contributor

👍

MorrisJobke added a commit that referenced this pull request Jan 8, 2015
@MorrisJobke
MorrisJobke merged commit 6a5f12b into master Jan 8, 2015
@MorrisJobke
MorrisJobke deleted the logfile_download branch January 8, 2015 23:33
@georgehrke georgehrke mentioned this pull request Jan 22, 2015
6 of 11 tasks
@oparoz oparoz mentioned this pull request Jan 22, 2015
1 of 2 tasks
@BernhardPosselt BernhardPosselt mentioned this pull request Jan 22, 2015
1 task done
BernhardPosselt pushed a commit that referenced this pull request Feb 16, 2015
First stab at the StreamResponse, see #12988

The idea is to use an interface ICallbackResponse (I'm not 100% happy with the name yet, suggestions?) that allow the response to output things in its own way, for instance stream the file using readfile

Unittests are atm lacking, plan is to

check if a mock of ICallbackResponse will be used by calling its callback (also unhappy with this name) method
Usage is:

$response = new StreamResponse('path/to/file');
BernhardPosselt pushed a commit that referenced this pull request Feb 27, 2015
First stab at the StreamResponse, see #12988

The idea is to use an interface ICallbackResponse (I'm not 100% happy with the name yet, suggestions?) that allow the response to output things in its own way, for instance stream the file using readfile

Unittests are atm lacking, plan is to

check if a mock of ICallbackResponse will be used by calling its callback (also unhappy with this name) method
Usage is:

$response = new StreamResponse('path/to/file');

rename io to output, add additional methods and handle error and not modified cases when using StreamResponse

fix indention and uppercasing, also handle forbidden cases

fix indention

fix indention

no forbidden, figuring out if a file is really readable is too complicated to get to work across OSes and streams

remove useless import

remove useless import

fix intendation
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 14, 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.

Option to download ownCloud log

8 participants