Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the develop branch, built from commit ac3fd2ab7e.
PrevUpHomeNext

Struct collector

boost::log::sinks::file::collector — Base class for file collectors.

Synopsis

// In header: <boost/log/sinks/text_file_backend.hpp>


struct collector {
  // construct/copy/destruct
  collector(collector const &) = delete;
  collector & operator=(collector const &) = delete;

  // public member functions
  virtual void store_file(filesystem::path const &) = 0;
  virtual bool is_in_storage(filesystem::path const &) const = 0;
  virtual scan_result 
  scan_for_files(scan_method, filesystem::path const & = filesystem::path()) = 0;
};

Description

All file collectors, supported by file sink backends, should inherit this class.

collector public construct/copy/destruct

  1. collector(collector const &) = delete;
  2. collector & operator=(collector const &) = delete;

collector public member functions

  1. virtual void store_file(filesystem::path const & src_path) = 0;

    Default constructor

    Virtual destructor

    The function stores the specified file in the storage. May lead to an older file deletion and a long file moving.

    Parameters:

    src_path

    The name of the file to be stored

  2. virtual bool is_in_storage(filesystem::path const & src_path) const = 0;

    The function checks if the specified path refers to an existing file in the storage.

    Parameters:

    src_path

    The path to be checked

  3. virtual scan_result 
    scan_for_files(scan_method method, 
                   filesystem::path const & pattern = filesystem::path()) = 0;

    Scans the target directory for the files that have already been stored. The found files are added to the collector in order to be tracked and erased, if needed.

    The function may scan the directory in two ways: it will either consider every file in the directory a log file, or will only consider files with names that match the specified pattern. The pattern may contain the following placeholders:

    • y, Y, m, d - date components, in Boost.DateTime meaning.

    • H, M, S, f - time components, in Boost.DateTime meaning.

    • N - numeric file counter. May also contain width specification in printf-compatible form (e.g. %5N). The resulting number will always be zero-filled.

    • %% - a percent sign

    All other placeholders are not supported.

    [Note] Note

    In case if method is scan_matching the effect of this function is highly dependent on the pattern definition. It is recommended to choose patterns with easily distinguished placeholders (i.e. having delimiters between them). Otherwise either some files can be mistakenly found or not found, which in turn may lead to deletion of an unintended file.

    Parameters:

    method

    The method of scanning. If no_scan is specified, the call has no effect.

    pattern

    The file name pattern if method is scan_matching. Otherwise the parameter is not used.

    Returns:

    The result of filesystem scanning. The last file counter is only populated if method is scan_matching, the pattern contains N placeholder, and at least one file matching the pattern is found.


PrevUpHomeNext