X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Fboost%2Flog%2Fsinks%2Ftext_file_backend.hpp;h=d72e4cfb53e1b276feaf1c24baf2d4a071b48aa3;hb=92f5a8d42d07f9929ae4fa7e01342fe8d96808a8;hp=899b5c49bcfca5c94acb4f1c1afb333a221e0868;hpb=a0324939f9d0e1905d5df8f57442f09dc70af83d;p=ceph.git diff --git a/ceph/src/boost/boost/log/sinks/text_file_backend.hpp b/ceph/src/boost/boost/log/sinks/text_file_backend.hpp index 899b5c49b..d72e4cfb5 100644 --- a/ceph/src/boost/boost/log/sinks/text_file_backend.hpp +++ b/ceph/src/boost/boost/log/sinks/text_file_backend.hpp @@ -30,15 +30,18 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include +#include #include #include #include @@ -371,7 +374,7 @@ public: * Constructor. Creates a sink backend with the specified named parameters. * The following named parameters are supported: * - * \li \c file_name - Specifies the file name pattern where logs are actually written to. The pattern may + * \li \c file_name - Specifies the active file name pattern where logs are actually written to. The pattern may * contain directory and file name portions, but only the file name may contain * placeholders. The backend supports Boost.DateTime placeholders for injecting * current time and date into the file name. Also, an additional %N placeholder is @@ -379,6 +382,10 @@ public: * may also contain width specification in the printf-compatible form (e.g. %5N). The * printed file counter will always be zero-filled. If \c file_name is not specified, * pattern "%5N.log" will be used. + * \li \c target_file_name - Specifies the target file name pattern to use to rename the log file on rotation, + * before passing it to the file collector. The pattern may contain the same + * placeholders as the \c file_name parameter. By default, no renaming is done, + * i.e. the written log file keeps its name according to \c file_name. * \li \c open_mode - File open mode. The mode should be presented in form of mask compatible to * std::ios_base::openmode. If not specified, trunc | out will be used. * \li \c rotation_size - Specifies the approximate size, in characters written, of the temporary file @@ -392,6 +399,8 @@ public: * sink backend destruction. By default, is \c true. * \li \c auto_flush - Specifies a flag, whether or not to automatically flush the file after each * written log record. By default, is \c false. + * \li \c auto_newline_mode - Specifies automatic trailing newline insertion mode. Must be a value of + * the \c auto_newline_mode enum. By default, is auto_newline_mode::insert_if_missing. * * \note Read the caution note regarding file name pattern in the sinks::file::collector::scan_for_files * documentation. @@ -409,7 +418,7 @@ public: BOOST_LOG_API ~text_file_backend(); /*! - * The method sets file name wildcard for the files being written. The wildcard supports + * The method sets the active file name wildcard for the files being written. The wildcard supports * date and time injection into the file name. * * \param pattern The name pattern for the file being written. @@ -420,6 +429,22 @@ public: set_file_name_pattern_internal(filesystem::path(pattern)); } + /*! + * The method sets the target file name wildcard for the files being rotated. The wildcard supports + * date and time injection into the file name. + * + * This pattern will be used when the log file is being rotated, to rename the just written + * log file (which has the name according to the pattern in the \c file_name constructor parameter or + * set by a call to \c set_file_name_pattern), just before passing the file to the file collector. + * + * \param pattern The name pattern for the file being rotated. + */ + template< typename PathT > + void set_target_file_name_pattern(PathT const& pattern) + { + set_target_file_name_pattern_internal(filesystem::path(pattern)); + } + /*! * The method sets the file open mode * @@ -491,6 +516,14 @@ public: */ BOOST_LOG_API void auto_flush(bool enable = true); + /*! + * Selects whether a trailing newline should be automatically inserted after every log record. See + * \c auto_newline_mode description for the possible modes of operation. + * + * \param mode The trailing newline insertion mode. + */ + BOOST_LOG_API void set_auto_newline_mode(auto_newline_mode mode); + /*! * \return The name of the currently open log file. If no file is open, returns an empty path. */ @@ -502,7 +535,7 @@ public: * as if they were rotated. * * The file scan can be performed in two ways: either all files in the target directory will - * be considered as log files, or only those files that satisfy the file name pattern. + * be considered as log files, or only those files that satisfy the target file name pattern. * See documentation on sinks::file::collector::scan_for_files for more information. * * \pre File collector and the proper file name pattern have already been set. @@ -541,23 +574,29 @@ private: { construct( filesystem::path(args[keywords::file_name | filesystem::path()]), + filesystem::path(args[keywords::target_file_name | filesystem::path()]), args[keywords::open_mode | (std::ios_base::trunc | std::ios_base::out)], args[keywords::rotation_size | (std::numeric_limits< uintmax_t >::max)()], args[keywords::time_based_rotation | time_based_rotation_predicate()], + args[keywords::auto_newline_mode | insert_if_missing], args[keywords::auto_flush | false], args[keywords::enable_final_rotation | true]); } //! Constructor implementation BOOST_LOG_API void construct( filesystem::path const& pattern, + filesystem::path const& target_file_name, std::ios_base::openmode mode, uintmax_t rotation_size, time_based_rotation_predicate const& time_based_rotation, + auto_newline_mode auto_newline, bool auto_flush, bool enable_final_rotation); - //! The method sets file name mask + //! The method sets file name pattern BOOST_LOG_API void set_file_name_pattern_internal(filesystem::path const& pattern); + //! The method sets target file name pattern + BOOST_LOG_API void set_target_file_name_pattern_internal(filesystem::path const& pattern); //! Closes the currently open file void close_file();