17 #ifndef __SLAVE_CONTAINER_LOGGER_LOGROTATE_HPP__
18 #define __SLAVE_CONTAINER_LOGGER_LOGROTATE_HPP__
38 const std::string
NAME =
"mesos-logrotate-logger";
47 "Usage: " +
NAME +
" [options]\n"
49 "This command pipes from STDIN to the given leading log file.\n"
50 "When the leading log file reaches '--max_size', the command.\n"
51 "uses 'logrotate' to rotate the logs. All 'logrotate' options\n"
52 "are supported. See '--logrotate_options'.\n"
57 "Maximum size, in bytes, of a single log file.\n"
58 "Defaults to 10 MB. Must be at least 1 (memory) page.",
63 "Expected --max_size of at least " +
71 "Additional config options to pass into 'logrotate'.\n"
72 "This string will be inserted into a 'logrotate' configuration file.\n"
74 " /path/to/<log_filename> {\n"
75 " <logrotate_options>\n"
78 "NOTE: The 'size' option will be overridden by this command.");
82 "Absolute path to the leading log file.\n"
83 "NOTE: This command will also create two files by appending\n"
85 "'--log_filename'. These files are used by 'logrotate'.",
88 return Error(
"Missing required option --log_filename");
92 return Error(
"Expected --log_filename to be an absolute path");
100 "If specified, this command will use the specified\n"
101 "'logrotate' instead of the system's 'logrotate'.",
111 "Failed to check logrotate: " + helpCommand.
error());
119 "The user this command should run as.");
134 #endif // __SLAVE_CONTAINER_LOGGER_LOGROTATE_HPP__
Definition: errorbase.hpp:35
Definition: logrotate.hpp:42
size_t pagesize()
Definition: pagesize.hpp:24
constexpr Bytes Megabytes(uint64_t value)
Definition: bytes.hpp:123
const std::string STATE_SUFFIX
Definition: logrotate.hpp:40
Bytes max_size
Definition: logrotate.hpp:122
const std::string NAME
Definition: logrotate.hpp:38
const std::string CONF_SUFFIX
Definition: logrotate.hpp:39
bool absolute(const std::string &path)
Returns whether the given path is an absolute path.
Definition: path.hpp:96
Option< std::string > user
Definition: logrotate.hpp:126
std::string logrotate_path
Definition: logrotate.hpp:125
void setUsageMessage(const std::string &message)
Definition: flags.hpp:164
const T & get() const &
Definition: option.hpp:118
Flags()
Definition: logrotate.hpp:44
static Try error(const E &e)
Definition: try.hpp:42
Try< std::string > shell(const std::string &fmt, const T &...t)
Runs a shell command with optional arguments.
Definition: shell.hpp:71
Option< std::string > log_filename
Definition: logrotate.hpp:124
bool isError() const
Definition: try.hpp:71
Option< std::string > logrotate_options
Definition: logrotate.hpp:123
constexpr char DEV_NULL[]
Definition: constants.hpp:30
uint64_t bytes() const
Definition: bytes.hpp:79
void add(T1 Flags::*t1, const Name &name, const Option< Name > &alias, const std::string &help, const T2 *t2, F validate)
Definition: flags.hpp:333
bool isNone() const
Definition: option.hpp:116
std::string stringify(int flags)