Turi Create  4.0
log_rotate.hpp
1 /* Copyright © 2017 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 #ifndef TURI_LOGGER_LOG_ROTATE_HPP
7 #define TURI_LOGGER_LOG_ROTATE_HPP
8 #include <cstddef>
9 #include <string>
10 namespace turi {
11 
12 /**
13  * \ingroup turilogger
14  *
15  * Sets up log rotation.
16  * The basic procedure is that it will generate files of the form
17  *
18  * \verbatim
19  * [log_file_name].0
20  * [log_file_name].1
21  * [log_file_name].2
22  * etc.
23  * \endverbatim
24  *
25  * When truncate_limit is set, a maximum number of files is maintained.
26  * Beyond which, older files are deleted.
27  *
28  * A symlink [log_file_name].current is also created which always points to the
29  * most recent log file.
30  *
31  * If log rotation has already been set up, this will stop
32  * the the log rotation and begin a new one.
33  *
34  * Not safe for concurrent use.
35  *
36  * \param log_file_name The prefix to output to. Logs will emit to
37  * [log_file_name].0, [log_file_name].1, etc.
38  * \param log_interval The number of seconds between rotations
39  * \param truncate_limit The maximum number of files to maintain. Must be >= 1
40  */
41 void begin_log_rotation(std::string log_file_name,
42  size_t log_interval,
43  size_t truncate_limit);
44 
45 /**
46  * Stops log rotation.
47  *
48  * No-op if log rotation was not started.
49  *
50  * Not safe for concurrent use.
51  */
52 void stop_log_rotation();
53 
54 } // turicreate
55 #endif // TURI_LOGGER_LOG_ROTATE_HPP
void stop_log_rotation()
void begin_log_rotation(std::string log_file_name, size_t log_interval, size_t truncate_limit)