text_file_backend.hpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. /*
  2. * Copyright Andrey Semashev 2007 - 2015.
  3. * Distributed under the Boost Software License, Version 1.0.
  4. * (See accompanying file LICENSE_1_0.txt or copy at
  5. * http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. /*!
  8. * \file text_file_backend.hpp
  9. * \author Andrey Semashev
  10. * \date 09.06.2009
  11. *
  12. * The header contains implementation of a text file sink backend.
  13. */
  14. #ifndef BOOST_LOG_SINKS_TEXT_FILE_BACKEND_HPP_INCLUDED_
  15. #define BOOST_LOG_SINKS_TEXT_FILE_BACKEND_HPP_INCLUDED_
  16. #include <ios>
  17. #include <string>
  18. #include <ostream>
  19. #include <boost/limits.hpp>
  20. #include <boost/cstdint.hpp>
  21. #include <boost/optional/optional.hpp>
  22. #include <boost/smart_ptr/shared_ptr.hpp>
  23. #include <boost/date_time/date_defs.hpp>
  24. #include <boost/date_time/special_defs.hpp>
  25. #include <boost/date_time/gregorian/greg_day.hpp>
  26. #include <boost/date_time/posix_time/posix_time_types.hpp>
  27. #include <boost/filesystem/path.hpp>
  28. #include <boost/log/keywords/max_size.hpp>
  29. #include <boost/log/keywords/max_files.hpp>
  30. #include <boost/log/keywords/min_free_space.hpp>
  31. #include <boost/log/keywords/target.hpp>
  32. #include <boost/log/keywords/target_file_name.hpp>
  33. #include <boost/log/keywords/file_name.hpp>
  34. #include <boost/log/keywords/open_mode.hpp>
  35. #include <boost/log/keywords/auto_flush.hpp>
  36. #include <boost/log/keywords/rotation_size.hpp>
  37. #include <boost/log/keywords/time_based_rotation.hpp>
  38. #include <boost/log/keywords/enable_final_rotation.hpp>
  39. #include <boost/log/keywords/auto_newline_mode.hpp>
  40. #include <boost/log/detail/config.hpp>
  41. #include <boost/log/detail/light_function.hpp>
  42. #include <boost/log/detail/parameter_tools.hpp>
  43. #include <boost/log/sinks/auto_newline_mode.hpp>
  44. #include <boost/log/sinks/basic_sink_backend.hpp>
  45. #include <boost/log/sinks/frontend_requirements.hpp>
  46. #include <boost/log/detail/header.hpp>
  47. #ifdef BOOST_HAS_PRAGMA_ONCE
  48. #pragma once
  49. #endif
  50. namespace boost {
  51. BOOST_LOG_OPEN_NAMESPACE
  52. namespace sinks {
  53. namespace file {
  54. //! The enumeration of the stored files scan methods
  55. enum scan_method
  56. {
  57. no_scan, //!< Don't scan for stored files
  58. scan_matching, //!< Scan for files with names matching the specified mask
  59. scan_all //!< Scan for all files in the directory
  60. };
  61. //! The structure contains filesystem scanning results
  62. struct scan_result
  63. {
  64. //! The number of found files
  65. uintmax_t found_count;
  66. //! If populated, the largest file counter that was used in the found file names
  67. boost::optional< unsigned int > last_file_counter;
  68. scan_result() BOOST_NOEXCEPT :
  69. found_count(0u)
  70. {
  71. }
  72. };
  73. /*!
  74. * \brief Base class for file collectors
  75. *
  76. * All file collectors, supported by file sink backends, should inherit this class.
  77. */
  78. struct BOOST_LOG_NO_VTABLE collector
  79. {
  80. /*!
  81. * Default constructor
  82. */
  83. BOOST_DEFAULTED_FUNCTION(collector(), {})
  84. /*!
  85. * Virtual destructor
  86. */
  87. #if !defined(BOOST_LOG_NO_CXX11_DEFAULTED_VIRTUAL_FUNCTIONS)
  88. BOOST_DEFAULTED_FUNCTION(virtual ~collector(), {})
  89. #else
  90. virtual ~collector() {}
  91. #endif
  92. /*!
  93. * The function stores the specified file in the storage. May lead to an older file
  94. * deletion and a long file moving.
  95. *
  96. * \param src_path The name of the file to be stored
  97. */
  98. virtual void store_file(filesystem::path const& src_path) = 0;
  99. /*!
  100. * The function checks if the specified path refers to an existing file in the storage.
  101. *
  102. * \param src_path The path to be checked
  103. */
  104. virtual bool is_in_storage(filesystem::path const& src_path) const = 0;
  105. /*!
  106. * Scans the target directory for the files that have already been stored. The found
  107. * files are added to the collector in order to be tracked and erased, if needed.
  108. *
  109. * The function may scan the directory in two ways: it will either consider every
  110. * file in the directory a log file, or will only consider files with names that
  111. * match the specified pattern. The pattern may contain the following placeholders:
  112. *
  113. * \li %y, %Y, %m, %d - date components, in Boost.DateTime meaning.
  114. * \li %H, %M, %S, %f - time components, in Boost.DateTime meaning.
  115. * \li %N - numeric file counter. May also contain width specification
  116. * in printf-compatible form (e.g. %5N). The resulting number will always be zero-filled.
  117. * \li %% - a percent sign
  118. *
  119. * All other placeholders are not supported.
  120. *
  121. * \param method The method of scanning. If \c no_scan is specified, the call has no effect.
  122. * \param pattern The file name pattern if \a method is \c scan_matching. Otherwise the parameter
  123. * is not used.
  124. * \return The result of filesystem scanning. The last file counter is only populated if
  125. * \a method is \c scan_matching, the \a pattern contains %N placeholder, and at least
  126. * one file matching the pattern is found.
  127. *
  128. * \note In case if \a method is \c scan_matching the effect of this function is highly dependent
  129. * on the \a pattern definition. It is recommended to choose patterns with easily
  130. * distinguished placeholders (i.e. having delimiters between them). Otherwise
  131. * either some files can be mistakenly found or not found, which in turn may lead
  132. * to deletion of an unintended file.
  133. */
  134. virtual scan_result scan_for_files(scan_method method, filesystem::path const& pattern = filesystem::path()) = 0;
  135. BOOST_DELETED_FUNCTION(collector(collector const&))
  136. BOOST_DELETED_FUNCTION(collector& operator= (collector const&))
  137. };
  138. namespace aux {
  139. //! Creates and returns a file collector with the specified parameters
  140. BOOST_LOG_API shared_ptr< collector > make_collector(
  141. filesystem::path const& target_dir,
  142. uintmax_t max_size,
  143. uintmax_t min_free_space,
  144. uintmax_t max_files = (std::numeric_limits< uintmax_t >::max)()
  145. );
  146. template< typename ArgsT >
  147. inline shared_ptr< collector > make_collector(ArgsT const& args)
  148. {
  149. return aux::make_collector(
  150. filesystem::path(args[keywords::target]),
  151. args[keywords::max_size | (std::numeric_limits< uintmax_t >::max)()],
  152. args[keywords::min_free_space | static_cast< uintmax_t >(0)],
  153. args[keywords::max_files | (std::numeric_limits< uintmax_t >::max)()]);
  154. }
  155. } // namespace aux
  156. #ifndef BOOST_LOG_DOXYGEN_PASS
  157. template< typename T1 >
  158. inline shared_ptr< collector > make_collector(T1 const& a1)
  159. {
  160. return aux::make_collector(a1);
  161. }
  162. template< typename T1, typename T2 >
  163. inline shared_ptr< collector > make_collector(T1 const& a1, T2 const& a2)
  164. {
  165. return aux::make_collector((a1, a2));
  166. }
  167. template< typename T1, typename T2, typename T3 >
  168. inline shared_ptr< collector > make_collector(T1 const& a1, T2 const& a2, T3 const& a3)
  169. {
  170. return aux::make_collector((a1, a2, a3));
  171. }
  172. template< typename T1, typename T2, typename T3, typename T4 >
  173. inline shared_ptr< collector > make_collector(T1 const& a1, T2 const& a2, T3 const& a3, T4 const& a4)
  174. {
  175. return aux::make_collector((a1, a2, a3, a4));
  176. }
  177. #else
  178. /*!
  179. * The function creates a file collector for the specified target directory.
  180. * Each target directory is managed by a single file collector, so if
  181. * this function is called several times for the same directory,
  182. * it will return a reference to the same file collector. It is safe
  183. * to use the same collector in different sinks, even in a multithreaded
  184. * application.
  185. *
  186. * One can specify certain restrictions for the stored files, such as
  187. * maximum total size or minimum free space left in the target directory.
  188. * If any of the specified restrictions is not met, the oldest stored file
  189. * is deleted. If the same collector is requested more than once with
  190. * different restrictions, the collector will act according to the most strict
  191. * combination of all specified restrictions.
  192. *
  193. * The following named parameters are supported:
  194. *
  195. * \li \c target - Specifies the target directory for the files being stored in. This parameter
  196. * is mandatory.
  197. * \li \c max_size - Specifies the maximum total size, in bytes, of stored files that the collector
  198. * will try not to exceed. If the size exceeds this threshold the oldest file(s) is
  199. * deleted to free space. Note that the threshold may be exceeded if the size of
  200. * individual files exceed the \c max_size value. The threshold is not maintained,
  201. * if not specified.
  202. * \li \c min_free_space - Specifies the minimum free space, in bytes, in the target directory that
  203. * the collector tries to maintain. If the threshold is exceeded, the oldest
  204. * file(s) is deleted to free space. The threshold is not maintained, if not
  205. * specified.
  206. * \li \c max_files - Specifies the maximum number of log files stored. If the number of files exceeds
  207. * this threshold, the oldest file(s) is deleted to free space. The threshhold is
  208. * not maintained if not specified.
  209. *
  210. * \return The file collector.
  211. */
  212. template< typename... ArgsT >
  213. shared_ptr< collector > make_collector(ArgsT... const& args);
  214. #endif // BOOST_LOG_DOXYGEN_PASS
  215. /*!
  216. * The class represents the time point of log file rotation. One can specify one of three
  217. * types of time point based rotation:
  218. *
  219. * \li rotation takes place every day, at the specified time
  220. * \li rotation takes place on the specified day of every week, at the specified time
  221. * \li rotation takes place on the specified day of every month, at the specified time
  222. *
  223. * The time points are considered to be local time.
  224. */
  225. class rotation_at_time_point
  226. {
  227. public:
  228. typedef bool result_type;
  229. private:
  230. enum day_kind
  231. {
  232. not_specified,
  233. weekday,
  234. monthday
  235. };
  236. unsigned char m_Day : 6;
  237. unsigned char m_DayKind : 2; // contains day_kind values
  238. unsigned char m_Hour, m_Minute, m_Second;
  239. mutable posix_time::ptime m_Previous;
  240. public:
  241. /*!
  242. * Creates a rotation time point of every day at the specified time
  243. *
  244. * \param hour The rotation hour, should be within 0 and 23
  245. * \param minute The rotation minute, should be within 0 and 59
  246. * \param second The rotation second, should be within 0 and 59
  247. */
  248. BOOST_LOG_API explicit rotation_at_time_point(unsigned char hour, unsigned char minute, unsigned char second);
  249. /*!
  250. * Creates a rotation time point of each specified weekday at the specified time
  251. *
  252. * \param wday The weekday of the rotation
  253. * \param hour The rotation hour, should be within 0 and 23
  254. * \param minute The rotation minute, should be within 0 and 59
  255. * \param second The rotation second, should be within 0 and 59
  256. */
  257. BOOST_LOG_API explicit rotation_at_time_point(
  258. date_time::weekdays wday,
  259. unsigned char hour = 0,
  260. unsigned char minute = 0,
  261. unsigned char second = 0);
  262. /*!
  263. * Creates a rotation time point of each specified day of month at the specified time
  264. *
  265. * \param mday The monthday of the rotation, should be within 1 and 31
  266. * \param hour The rotation hour, should be within 0 and 23
  267. * \param minute The rotation minute, should be within 0 and 59
  268. * \param second The rotation second, should be within 0 and 59
  269. */
  270. BOOST_LOG_API explicit rotation_at_time_point(
  271. gregorian::greg_day mday,
  272. unsigned char hour = 0,
  273. unsigned char minute = 0,
  274. unsigned char second = 0);
  275. /*!
  276. * Checks if it's time to rotate the file
  277. */
  278. BOOST_LOG_API bool operator() () const;
  279. };
  280. /*!
  281. * The class represents the time interval of log file rotation. The log file will be rotated
  282. * after the specified time interval has passed.
  283. */
  284. class rotation_at_time_interval
  285. {
  286. public:
  287. typedef bool result_type;
  288. private:
  289. posix_time::time_duration m_Interval;
  290. mutable posix_time::ptime m_Previous;
  291. public:
  292. /*!
  293. * Creates a rotation time interval of the specified duration
  294. *
  295. * \param interval The interval of the rotation, should be no less than 1 second
  296. */
  297. explicit rotation_at_time_interval(posix_time::time_duration const& interval) :
  298. m_Interval(interval)
  299. {
  300. BOOST_ASSERT(!interval.is_special());
  301. BOOST_ASSERT(interval.total_seconds() > 0);
  302. }
  303. /*!
  304. * Checks if it's time to rotate the file
  305. */
  306. BOOST_LOG_API bool operator() () const;
  307. };
  308. } // namespace file
  309. /*!
  310. * \brief An implementation of a text file logging sink backend
  311. *
  312. * The sink backend puts formatted log records to a text file.
  313. * The sink supports file rotation and advanced file control, such as
  314. * size and file count restriction.
  315. */
  316. class text_file_backend :
  317. public basic_formatted_sink_backend<
  318. char,
  319. combine_requirements< synchronized_feeding, flushing >::type
  320. >
  321. {
  322. //! Base type
  323. typedef basic_formatted_sink_backend<
  324. char,
  325. combine_requirements< synchronized_feeding, flushing >::type
  326. > base_type;
  327. public:
  328. //! Character type
  329. typedef base_type::char_type char_type;
  330. //! String type to be used as a message text holder
  331. typedef base_type::string_type string_type;
  332. //! Stream type
  333. typedef std::basic_ostream< char_type > stream_type;
  334. //! File open handler
  335. typedef boost::log::aux::light_function< void (stream_type&) > open_handler_type;
  336. //! File close handler
  337. typedef boost::log::aux::light_function< void (stream_type&) > close_handler_type;
  338. //! Predicate that defines the time-based condition for file rotation
  339. typedef boost::log::aux::light_function< bool () > time_based_rotation_predicate;
  340. private:
  341. //! \cond
  342. struct implementation;
  343. implementation* m_pImpl;
  344. //! \endcond
  345. public:
  346. /*!
  347. * Default constructor. The constructed sink backend uses default values of all the parameters.
  348. */
  349. BOOST_LOG_API text_file_backend();
  350. /*!
  351. * Constructor. Creates a sink backend with the specified named parameters.
  352. * The following named parameters are supported:
  353. *
  354. * \li \c file_name - Specifies the active file name pattern where logs are actually written to. The pattern may
  355. * contain directory and file name portions, but only the file name may contain
  356. * placeholders. The backend supports Boost.DateTime placeholders for injecting
  357. * current time and date into the file name. Also, an additional %N placeholder is
  358. * supported, it will be replaced with an integral increasing file counter. The placeholder
  359. * may also contain width specification in the printf-compatible form (e.g. %5N). The
  360. * printed file counter will always be zero-filled. If \c file_name is not specified,
  361. * pattern "%5N.log" will be used.
  362. * \li \c target_file_name - Specifies the target file name pattern to use to rename the log file on rotation,
  363. * before passing it to the file collector. The pattern may contain the same
  364. * placeholders as the \c file_name parameter. By default, no renaming is done,
  365. * i.e. the written log file keeps its name according to \c file_name.
  366. * \li \c open_mode - File open mode. The mode should be presented in form of mask compatible to
  367. * <tt>std::ios_base::openmode</tt>. If not specified, <tt>trunc | out</tt> will be used.
  368. * \li \c rotation_size - Specifies the approximate size, in characters written, of the temporary file
  369. * upon which the file is passed to the file collector. Note the size does
  370. * not count any possible character conversions that may take place during
  371. * writing to the file. If not specified, the file won't be rotated upon reaching
  372. * any size.
  373. * \li \c time_based_rotation - Specifies the predicate for time-based file rotation.
  374. * No time-based file rotations will be performed, if not specified.
  375. * \li \c enable_final_rotation - Specifies a flag, whether or not perform log file rotation on
  376. * sink backend destruction. By default, is \c true.
  377. * \li \c auto_flush - Specifies a flag, whether or not to automatically flush the file after each
  378. * written log record. By default, is \c false.
  379. * \li \c auto_newline_mode - Specifies automatic trailing newline insertion mode. Must be a value of
  380. * the \c auto_newline_mode enum. By default, is <tt>auto_newline_mode::insert_if_missing</tt>.
  381. *
  382. * \note Read the caution note regarding file name pattern in the <tt>sinks::file::collector::scan_for_files</tt>
  383. * documentation.
  384. */
  385. #ifndef BOOST_LOG_DOXYGEN_PASS
  386. BOOST_LOG_PARAMETRIZED_CONSTRUCTORS_CALL(text_file_backend, construct)
  387. #else
  388. template< typename... ArgsT >
  389. explicit text_file_backend(ArgsT... const& args);
  390. #endif
  391. /*!
  392. * Destructor
  393. */
  394. BOOST_LOG_API ~text_file_backend();
  395. /*!
  396. * The method sets the active file name wildcard for the files being written. The wildcard supports
  397. * date and time injection into the file name.
  398. *
  399. * \param pattern The name pattern for the file being written.
  400. */
  401. template< typename PathT >
  402. void set_file_name_pattern(PathT const& pattern)
  403. {
  404. set_file_name_pattern_internal(filesystem::path(pattern));
  405. }
  406. /*!
  407. * The method sets the target file name wildcard for the files being rotated. The wildcard supports
  408. * date and time injection into the file name.
  409. *
  410. * This pattern will be used when the log file is being rotated, to rename the just written
  411. * log file (which has the name according to the pattern in the \c file_name constructor parameter or
  412. * set by a call to \c set_file_name_pattern), just before passing the file to the file collector.
  413. *
  414. * \param pattern The name pattern for the file being rotated.
  415. */
  416. template< typename PathT >
  417. void set_target_file_name_pattern(PathT const& pattern)
  418. {
  419. set_target_file_name_pattern_internal(filesystem::path(pattern));
  420. }
  421. /*!
  422. * The method sets the file open mode
  423. *
  424. * \param mode File open mode
  425. */
  426. BOOST_LOG_API void set_open_mode(std::ios_base::openmode mode);
  427. /*!
  428. * The method sets the log file collector function. The function is called
  429. * on file rotation and is being passed the written file name.
  430. *
  431. * \param collector The file collector function object
  432. */
  433. BOOST_LOG_API void set_file_collector(shared_ptr< file::collector > const& collector);
  434. /*!
  435. * The method sets file opening handler. The handler will be called every time
  436. * the backend opens a new temporary file. The handler may write a header to the
  437. * opened file in order to maintain file validity.
  438. *
  439. * \param handler The file open handler function object
  440. */
  441. BOOST_LOG_API void set_open_handler(open_handler_type const& handler);
  442. /*!
  443. * The method sets file closing handler. The handler will be called every time
  444. * the backend closes a temporary file. The handler may write a footer to the
  445. * opened file in order to maintain file validity.
  446. *
  447. * \param handler The file close handler function object
  448. */
  449. BOOST_LOG_API void set_close_handler(close_handler_type const& handler);
  450. /*!
  451. * The method sets maximum file size. When the size is reached, file rotation is performed.
  452. *
  453. * \note The size does not count any possible character translations that may happen in
  454. * the underlying API. This may result in greater actual sizes of the written files.
  455. *
  456. * \param size The maximum file size, in characters.
  457. */
  458. BOOST_LOG_API void set_rotation_size(uintmax_t size);
  459. /*!
  460. * The method sets the predicate that defines the time-based condition for file rotation.
  461. *
  462. * \note The rotation always occurs on writing a log record, so the rotation is
  463. * not strictly bound to the specified condition.
  464. *
  465. * \param predicate The predicate that defines the time-based condition for file rotation.
  466. * If empty, no time-based rotation will take place.
  467. */
  468. BOOST_LOG_API void set_time_based_rotation(time_based_rotation_predicate const& predicate);
  469. /*!
  470. * The method allows to enable or disable log file rotation on sink destruction.
  471. *
  472. * By default the sink backend will rotate the log file, if it's been written to, on
  473. * destruction.
  474. *
  475. * \param enable The flag indicates whether the final rotation should be performed.
  476. */
  477. BOOST_LOG_API void enable_final_rotation(bool enable);
  478. /*!
  479. * Sets the flag to automatically flush write buffers of the file being written after each log record.
  480. *
  481. * \param enable The flag indicates whether the automatic buffer flush should be performed.
  482. */
  483. BOOST_LOG_API void auto_flush(bool enable = true);
  484. /*!
  485. * Selects whether a trailing newline should be automatically inserted after every log record. See
  486. * \c auto_newline_mode description for the possible modes of operation.
  487. *
  488. * \param mode The trailing newline insertion mode.
  489. */
  490. BOOST_LOG_API void set_auto_newline_mode(auto_newline_mode mode);
  491. /*!
  492. * \return The name of the currently open log file. If no file is open, returns an empty path.
  493. */
  494. BOOST_LOG_API filesystem::path get_current_file_name() const;
  495. /*!
  496. * Performs scanning of the target directory for log files that may have been left from
  497. * previous runs of the application. The found files are considered by the file collector
  498. * as if they were rotated.
  499. *
  500. * The file scan can be performed in two ways: either all files in the target directory will
  501. * be considered as log files, or only those files that satisfy the target file name pattern.
  502. * See documentation on <tt>sinks::file::collector::scan_for_files</tt> for more information.
  503. *
  504. * \pre File collector and the proper file name pattern have already been set.
  505. *
  506. * \param method File scanning method
  507. * \param update_counter If \c true and \a method is \c scan_matching, the method attempts
  508. * to update the internal file counter according to the found files. The counter
  509. * is unaffected otherwise.
  510. * \return The number of files found.
  511. *
  512. * \note The method essentially delegates to the same-named function of the file collector.
  513. */
  514. BOOST_LOG_API uintmax_t scan_for_files(
  515. file::scan_method method = file::scan_matching, bool update_counter = true);
  516. /*!
  517. * The method writes the message to the sink
  518. */
  519. BOOST_LOG_API void consume(record_view const& rec, string_type const& formatted_message);
  520. /*!
  521. * The method flushes the currently open log file
  522. */
  523. BOOST_LOG_API void flush();
  524. /*!
  525. * The method rotates the file
  526. */
  527. BOOST_LOG_API void rotate_file();
  528. private:
  529. #ifndef BOOST_LOG_DOXYGEN_PASS
  530. //! Constructor implementation
  531. template< typename ArgsT >
  532. void construct(ArgsT const& args)
  533. {
  534. construct(
  535. filesystem::path(args[keywords::file_name | filesystem::path()]),
  536. filesystem::path(args[keywords::target_file_name | filesystem::path()]),
  537. args[keywords::open_mode | (std::ios_base::trunc | std::ios_base::out)],
  538. args[keywords::rotation_size | (std::numeric_limits< uintmax_t >::max)()],
  539. args[keywords::time_based_rotation | time_based_rotation_predicate()],
  540. args[keywords::auto_newline_mode | insert_if_missing],
  541. args[keywords::auto_flush | false],
  542. args[keywords::enable_final_rotation | true]);
  543. }
  544. //! Constructor implementation
  545. BOOST_LOG_API void construct(
  546. filesystem::path const& pattern,
  547. filesystem::path const& target_file_name,
  548. std::ios_base::openmode mode,
  549. uintmax_t rotation_size,
  550. time_based_rotation_predicate const& time_based_rotation,
  551. auto_newline_mode auto_newline,
  552. bool auto_flush,
  553. bool enable_final_rotation);
  554. //! The method sets file name pattern
  555. BOOST_LOG_API void set_file_name_pattern_internal(filesystem::path const& pattern);
  556. //! The method sets target file name pattern
  557. BOOST_LOG_API void set_target_file_name_pattern_internal(filesystem::path const& pattern);
  558. //! Closes the currently open file
  559. void close_file();
  560. #endif // BOOST_LOG_DOXYGEN_PASS
  561. };
  562. } // namespace sinks
  563. BOOST_LOG_CLOSE_NAMESPACE // namespace log
  564. } // namespace boost
  565. #include <boost/log/detail/footer.hpp>
  566. #endif // BOOST_LOG_SINKS_TEXT_FILE_BACKEND_HPP_INCLUDED_