-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[🚀 Feature]: Ability to overwrite files when using FileLogHandler #13860
Comments
@MJB222398, thank you for creating this issue. We will troubleshoot it as soon as we can. Info for maintainersTriage this issue by using labels.
If information is missing, add a helpful comment and then
If the issue is a question, add the
If the issue is valid but there is no time to troubleshoot it, consider adding the
If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C),
add the applicable
After troubleshooting the issue, please add the Thank you! |
This issue is looking for contributors. Please comment below or reach out to us through our IRC/Slack/Matrix channels if you are interested. |
It is good idea. I am curious whether reserving I vote for optional argument: public FileLogHandler(string filePath, bool overwrite = false) In this case we should double-check whether introducing new optional argument is breaking change (it is not at compilation level, I am not sure about binary level). @YevgeniyShunevych your input is highly appreciated. |
Or the constructor could take an "options" object that could be extended whenever more configuration is required and then that way the constructor signature won't change after this point. |
Agree, that can be a useful ability. Adding an extra optional parameter, such as But if we really expect some other parameters in the future, then options class looks a better way. But anyway I would add the second constructor, considering a binary breaking change. public class FileLogHandler
{
public FileLogHandler(string filePath)
: this(filePath, FileLogHandlerOptions.Default)
{
}
public FileLogHandler(string filePath, FileLogHandlerOptions options)
{
//...
}
}
public sealed class FileLogHandlerOptions
{
public static FileLogHandlerOptions Default { get; } = new FileLogHandlerOptions();
public bool Override { get; init; }
} |
Thank you guys! In summary, we should choose between: ctor FileLogHandler(string filePath);
ctor FileLogHandler(string filePath, bool overwrite = false); ctor FileLogHandler(string filePath);
ctor FileLogHandler(string filePath, FileLogHandlerOptions options); The second option dictates to apply this good pattern (how to avoid breaking changes) anywhere! I don't think it is good idea, at least this pattern is not spread widely in BCL. Our class is pretty simple, we don't expect new "flags" (at least how I feel it). But the second option is CLS-compliant (lol, should we). In any case user is able to implement his own Just to confirm, is the following is a breaking change? ctor FileLogHandler(string filePath);
ctor FileLogHandler(string filePath, bool overwrite = false); After: ctor FileLogHandler(string filePath);
ctor FileLogHandler(string filePath, bool overwrite = false, bool someOtherArg = false); |
This issue has been automatically locked since there has not been any recent activity since it was closed. Please open a new issue for related bugs. |
Feature and motivation
I want to make use of FileLogHandler to output driver logs to the filesystem for the testing suite (one file per test). Currently this only supports appending logs to the file. I do not need to keep logs from previous test runs and would prefer to create new files each time so that I only have the relevant logs.
Usage example
The solution could be as simple as having an overload constructor for the FileLogHandler:
public FileLogHandler(string filePath, bool overwriteExisting)
The text was updated successfully, but these errors were encountered: