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

Issue #23 workaround #24

Merged
merged 2 commits into from
Nov 14, 2016
Merged

Issue #23 workaround #24

merged 2 commits into from
Nov 14, 2016

Conversation

EamonHetherton
Copy link
Contributor

@EamonHetherton EamonHetherton commented Nov 11, 2016

Tests to demonstrate the issue and a workaround for it. I wouldn't consider the workaround a final solution though.

Copy link
Member

@nblumhardt nblumhardt left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple of thoughts.

@@ -60,7 +60,7 @@ public override long Position

public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException();
return _stream.Seek(offset, origin);
Copy link
Member

Choose a reason for hiding this comment

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

Would the workaround be impacted if we continue to throw here? Although it appears to break the CanSeek/Seek() contract, actually calling Seek() would break the write counting. Perhaps as a compromise we could throw InvalidOperationException() instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is the WriteCountingStream actually necessary at all? For what I can see, being a private sealed class with only a single usage within the project, it exists only to support a file size limit. In this case it seems to me that a regular FIleStream would be sufficient by using the Length property and more robust to boot. No functionality of the actual stream would need to be wrapped and turned of either, like Seek. Am I missing something?

Copy link
Member

Choose a reason for hiding this comment

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

It's a good question. FileStream.Length turns out to be a couple of orders of magnitude slower, as it calls through to get the file size from the OS (at least, that's my recollection from testing it).

Open to scrapping it, but would need to re-do benchmarking. There's a small sample app in the solution that gives some basic write throughput numbers if you're keen to check it out - I'll have another look when I get a chance 👍

@@ -0,0 +1,25 @@
using Serilog.Formatting;
Copy link
Member

Choose a reason for hiding this comment

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

Convention in the test project is for these to go into the Support namespace/folder.

@nblumhardt
Copy link
Member

Hi Eamon, I will make these changes by hand on the way "through the works" - thanks again for the investigation and PR.

@nblumhardt nblumhardt merged commit 2fa2921 into serilog:dev Nov 14, 2016
@nblumhardt nblumhardt mentioned this pull request Nov 14, 2016
@EamonHetherton
Copy link
Contributor Author

Thanks Nic, I unplugged for the weekend so would have got to this today otherwise.

@nblumhardt
Copy link
Member

Unplugging over the weekend is a good policy, I try to do the same :-) ... If you have a chance to spin up the 3.1.1 dev build it would be great to get the extra validation that all is working smoothly now. Cheers!

@EamonHetherton
Copy link
Contributor Author

just a few quick checks with Serilog.Sinks.File 3.1.1-dev-00754 and the issue appears solved with this version.

@nblumhardt
Copy link
Member

Great, thanks. #25 will push this through to master once I've done some more testing on different configurations here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants