std.experimental.logger.filelogger - D Programming Language
Description: D Programming Language
Keywords: D programming language

Menu

- Learn
- Documentation
  - Language Reference
  - Library Reference
  - Command-line Reference
  - Feature Overview
  - Articles
- Packages
- Community
  - Blog
  - Orgs using D
  - Twitter
  - Forums
  - IRC
  - Wiki
  - GitHub
  - Issues
  - Foundation
  - Donate
- Resources
  - Books
  - Tutorials
  - Tools
  - Editors
  - IDEs
  - Visual D
  - Acknowledgments
  - D Style
  - Glossary
  - Sitemap

Search
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using a local clone.

# std.experimental.logger.filelogger

class `FileLogger`: std.experimental.logger.core.Logger;
  This Logger implementation 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(in string `fn`, const LogLevel `lv` = LogLevel.all);
    A constructor for the FileLogger Logger.
    Parameters:

    string `fn` | The filename of the output file of the FileLogger. If that file can not be opened for writting an exception will be thrown.
    LogLevel `lv` | The LogLevel for the FileLogger. By default the LogLevel for FileLogger is LogLevel.all.

    Example:

        auto l1 = new FileLogger("logFile");
        auto l2 = new FileLogger("logFile", LogLevel.fatal);

  @safe this(File `file`, const LogLevel `lv` = LogLevel.all);
    A constructor for the FileLogger Logger that takes a reference to a File.
    The File passed must be open for all the log call to the FileLogger. If the File gets closed, using the FileLogger for logging will result in undefined behaviour.
    Parameters:

    File `file` | The `file` used for logging.
    LogLevel `lv` | The LogLevel for the FileLogger. By default the LogLevel for FileLogger is LogLevel.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 FileLogger is managing the File it logs to, this method will return a reference to this File.
  string `getFilename`();
    If the FileLogger was constructed with a filename, this method returns this filename. Otherwise an empty string is returned.

Copyright © 1999-2017 by the D Language Foundation | Page generated by Ddoc on Thu Mar 9 17:49:43 2017