www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15771] New: FileLogger should create the output directory if


          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 puremagic.com
          Reporter: minasm1990 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 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).

Mar 06 2016