Skip to content

Fix Issue 15771 - FileLogger should create the output directory if it does not exist#5594

Merged
dlang-bot merged 1 commit intodlang:masterfrom
RazvanN7:Issue_15771
Jul 12, 2017
Merged

Fix Issue 15771 - FileLogger should create the output directory if it does not exist#5594
dlang-bot merged 1 commit intodlang:masterfrom
RazvanN7:Issue_15771

Conversation

@RazvanN7
Copy link
Collaborator

I added an optional parameter to the constructor of FileLogger which specifies if the Logger should create the directory path offered. It defaults to false.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @RazvanN7! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.

Some tips to help speed things up:

  • smaller, focused PRs are easier to review than big ones

  • try not to mix up refactoring or style changes with bug fixes or feature enhancements

  • provide helpful commit messages explaining the rationale behind each change

Bear in mind that large or tricky changes may require multiple rounds of review and revision.

Please see CONTRIBUTING.md for more information.

Bugzilla references

Auto-close Bugzilla Description
15771 FileLogger should create the output directory if it does not exist

@wilzbach
Copy link
Contributor

Has anyone an idea why the CODEOWNERS file didn't work here?
https://github.com/dlang/phobos/blob/master/CODEOWNERS#L38 clears maps @burner to std.experimental.logger

@wilzbach
Copy link
Contributor

Btw @RazvanN7 you should really search through the existing PR queue before working on a fix:

#5370

@aG0aep6G
Copy link
Contributor

Btw @RazvanN7 you should really search through the existing PR queue before working on a fix

People should leave links to their PRs on the Bugzilla pages.

@RazvanN7
Copy link
Collaborator Author

RazvanN7 commented Jul 11, 2017

Damn... I usually try to reproduce the bug and if that happens I assume that nobody has fixed it. Obviously not such a good methodology. So how do we go on from here? Should I close this?

@JackStouffer
Copy link
Contributor

People should leave links to their PRs on the Bugzilla pages.

But people forget (maybe the bot should).

So how do we go on from here? Should I close this?

Yeah, @burner's PR is a bit more polished.

@wilzbach
Copy link
Contributor

wilzbach commented Jul 11, 2017

But people forget (maybe the bot should).

-> dlang/dlang-bot#135

Yeah, @burner's PR is a bit more polished.

@RazvanN7 feel free to copy the code from @burner's PR if you want to continue with this. You seem a bit more active currently ;-)
Otherwise please close yourself.

@RazvanN7
Copy link
Collaborator Author

@wilzbach Since @burner seemed to not have time for this, I took the liberty of pasting his code and mix in the review comments. Hope this does it

Copy link
Contributor

@wilzbach wilzbach left a comment

Choose a reason for hiding this comment

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

Thanks a lot @RazvanN7 - fix the CI error + nits and then I think we're finally good to go.

assert(!exists(filepath));

auto f = new FileLogger(filename, LogLevel.all, CreateFolder.yes);
scope(exit) () @trusted { rmdirRecurse(tmpFolder ~ "/bug15771"); }();
Copy link
Contributor

Choose a reason for hiding this comment

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

Params:
file = The file used for logging.
lv = The $(D LogLevel) for the $(D FileLogger). By default the
$(D LogLevel) for $(D FileLogger) is $(D LogLevel.all).
Copy link
Contributor

Choose a reason for hiding this comment

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

CI error:

std/experimental/logger/filelogger.d(40): Warning: Ddoc: function declaration has no parameter 'createFileNameFolder'
std/experimental/logger/filelogger.d(40): Warning: Ddoc: parameter count mismatch
std/experimental/logger/filelogger.d(64): Warning: Ddoc: function declaration has no parameter 'file'
std/experimental/logger/filelogger.d(64): Warning: Ddoc: parameter count mismatch

Better rename fn etc. in the first overload as well then.

{
import std.file : rmdirRecurse, exists;
import std.path : dirName;
import std.file : deleteme;
Copy link
Contributor

Choose a reason for hiding this comment

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

Combine with the first import?


import std.typecons : Flag;

/** An option for a $(D FileLogger) constructor to possibly create the folder the
Copy link
Contributor

Choose a reason for hiding this comment

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

How about: "to create $(LREF FileLogger) directory if it's not existent?"

{
auto d = dirName(this.filename);
mkdirRecurse(d);
assert(exists(d), text("The folder the FileLogger should have been",
Copy link
Contributor

Choose a reason for hiding this comment

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

s/have been/have/ or "should have been created by the FileLogger"

@RazvanN7
Copy link
Collaborator Author

@wilzbach done. hope this does it.

@burner
Copy link
Member

burner commented Jul 12, 2017

@RazvanN7 could you squash and then I'll merge this

@RazvanN7
Copy link
Collaborator Author

@burner Done. Sorry for taking your code like that 🗡️

@dlang-bot dlang-bot merged commit d27a3bf into dlang:master Jul 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants