std.experimental.logger.filelogger
- alias CreateFolder = std.typecons.Flag!"CreateFolder".Flag;
-
An option to create
FileLoggerdirectory if it is non-existent. - class FileLogger: std.experimental.logger.core.Logger;
-
This
Loggerimplementation writes log messages to the associated file. The name of the file has to be passed on construction time. If the file is already present new log messages will be append at its end.- @safe this(const string fn, const LogLevel lv = LogLevel.all);
-
A constructor for the
FileLoggerLogger.- Parameters:
string fnThe filename of the output file of the FileLogger. If that file can not be opened for writting an exception will be thrown.LogLevel lvThe LogLevelfor theFileLogger. By default the
- Example
auto l1 = new FileLogger("logFile"); auto l2 = new FileLogger("logFile", LogLevel.fatal); auto l3 = new FileLogger("logFile", LogLevel.fatal, CreateFolder.yes); - @safe this(const string fn, const LogLevel lv, CreateFolder createFileNameFolder);
-
A constructor for the
FileLoggerLogger that takes a reference to aFile.The
Filepassed must be open for all the log call to theFileLogger. If theFilegets closed, using theFileLoggerfor logging will result in undefined behaviour.- Parameters:
string fnThe file used for logging. LogLevel lvThe LogLevelfor theFileLogger. By default theLogLevelforFileLoggerisLogLevel.all.CreateFolder createFileNameFolderif yes and fn contains a folder name, this folder will be created.
- Example
auto file = File("logFile.log", "w"); auto l1 = new FileLogger(file); auto l2 = new FileLogger(file, LogLevel.fatal); - @safe this(File file, const LogLevel lv = LogLevel.all);
-
A constructor for the
FileLoggerLogger that takes a reference to aFile.The
Filepassed must be open for all the log call to theFileLogger. If theFilegets closed, using theFileLoggerfor logging will result in undefined behaviour.- Parameters:
File fileThe file used for logging. LogLevel lvThe LogLevelfor theFileLogger. By default theLogLevelforFileLoggerisLogLevel.all.
- Example
auto file = File("logFile.log", "w"); auto l1 = new FileLogger(file); auto l2 = new FileLogger(file, LogLevel.fatal); - @property @safe File file();
-
If the
FileLoggeris managing theFileit logs to, this method will return a reference to this File. - string getFilename();
-
If the
FileLoggerwas constructed with a filename, this method returns this filename. Otherwise an emptystringis returned. - protected File file_;
-
The
Filelog messages are written to. - protected string filename;
-
The filename of the
Filelog messages are written to.
© 1999–2021 The D Language Foundation
Licensed under the Boost License 1.0.
https://dlang.org/phobos/std_experimental_logger_filelogger.html