|
5 | 5 | #include <algorithm>
|
6 | 6 | #include <cstdlib>
|
7 | 7 | #include <map>
|
| 8 | +#include <sstream> |
8 | 9 |
|
9 | 10 | #include "cmdline.h"
|
10 | 11 | #include "ulog/file/async_rotating_file.h"
|
11 | 12 | #include "ulog/file/zstd_file_writer.h"
|
12 |
| -#include "ulog/queue/mpsc_ring.h" |
13 | 13 | #include "ulog/queue/spsc_ring.h"
|
14 | 14 |
|
15 | 15 | #define ZSTD_DEFAULT_LEVEL 3
|
@@ -68,15 +68,15 @@ int main(const int argc, char *argv[]) {
|
68 | 68 | const auto fifo_size = std::max(to_bytes(args_info.fifo_size_arg), 16ULL * 1024);
|
69 | 69 | const auto file_size = to_bytes(args_info.file_size_arg);
|
70 | 70 | const auto flush_interval = to_chrono_time(args_info.flush_interval_arg);
|
71 |
| - std::string filepath = args_info.file_path_arg; |
| 71 | + std::string filename = args_info.file_path_arg; |
72 | 72 |
|
73 | 73 | std::unique_ptr<ulog::file::WriterInterface> file_writer;
|
74 | 74 | // Zstd compression
|
75 | 75 | if (args_info.zstd_compress_flag) {
|
76 | 76 | // Append .zst extension if not present
|
77 | 77 | std::string basename, ext;
|
78 |
| - std::tie(basename, ext) = ulog::file::SplitByExtension(filepath); |
79 |
| - if (ext.find(".zst") == std::string::npos) filepath += ".zst"; |
| 78 | + std::tie(basename, ext) = ulog::file::SplitByExtension(filename); |
| 79 | + if (ext.find(".zst") == std::string::npos) filename += ".zst"; |
80 | 80 |
|
81 | 81 | // Parse zstd parameters
|
82 | 82 | if (args_info.zstd_params_given) {
|
@@ -105,9 +105,15 @@ int main(const int argc, char *argv[]) {
|
105 | 105 | ? ulog::file::RotationStrategy::kIncrement
|
106 | 106 | : ulog::file::RotationStrategy::kRename;
|
107 | 107 |
|
108 |
| - const ulog::file::AsyncRotatingFile<ulog::spsc::Mq<uint8_t>> async_rotate( |
109 |
| - std::move(file_writer), fifo_size, filepath, args_info.max_files_arg, args_info.rotate_first_flag, flush_interval, |
110 |
| - rotation_strategy); |
| 108 | + ulog::file::AsyncRotatingFile<ulog::spsc::Mq<>>::Config config; |
| 109 | + config.fifo_size = fifo_size; |
| 110 | + config.filename = filename; |
| 111 | + config.max_files = args_info.max_files_arg; |
| 112 | + config.rotate_on_open = args_info.rotate_first_flag; |
| 113 | + config.max_flush_period = flush_interval; |
| 114 | + config.rotation_strategy = rotation_strategy; |
| 115 | + |
| 116 | + const ulog::file::AsyncRotatingFile<ulog::spsc::Mq<>> async_rotate(std::move(file_writer), config); |
111 | 117 |
|
112 | 118 | cmdline_parser_free(&args_info);
|
113 | 119 |
|
|
0 commit comments