[Issue 15771] New: FileLogger should create the output directory if it does not exist
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Mar 6 01:47:32 PST 2016
https://issues.dlang.org/show_bug.cgi?id=15771
Issue ID: 15771
Summary: FileLogger should create the output directory if it
does not exist
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: minasm1990 at gmail.com
Currectly, this throws an exception, because the folder "oops" does not exist.
//
import std.experimental.logger;
void main()
{
auto logger = new FileLogger("/home/minas/oops/log.txt");
}
//
std.exception.ErrnoException at std/stdio.d(393): Cannot open file
`/home/minas/oops/log.txt' in mode `a' (No such file or directory)
The solution is simple: mkdirRecurse("/home/minas/oops/");
However, this is something that the logging system should be doing, not the
client programmer.
(As an example Java's logback and log4j create the directory structure if it's
not there).
--
More information about the Digitalmars-d-bugs
mailing list