forked from quickshell/quickshell
core/command: add log --follow
This commit is contained in:
parent
c78381f6d0
commit
a82fbf40c2
8 changed files with 262 additions and 63 deletions
|
@ -96,6 +96,7 @@ struct CommandState {
|
|||
bool sparse = false;
|
||||
size_t verbosity = 0;
|
||||
int tail = 0;
|
||||
bool follow = false;
|
||||
QStringOption rules;
|
||||
QStringOption readoutRules;
|
||||
QStringOption file;
|
||||
|
@ -241,13 +242,10 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
|
|||
}
|
||||
|
||||
{
|
||||
auto* sub = cli.add_subcommand(
|
||||
"log",
|
||||
"Read quickshell logs.\n"
|
||||
"If --file is specified, the given file will be read.\n"
|
||||
"If not, the log of the first launched instance matching"
|
||||
"the instance selection flags will be read."
|
||||
);
|
||||
auto* sub = cli.add_subcommand("log", "Read quickshell logs.\n")
|
||||
->description("If --file is specified, the given file will be read.\n"
|
||||
"If not, the log of the first launched instance matching"
|
||||
"the instance selection flags will be read.");
|
||||
|
||||
auto* file = sub->add_option("--file", state.log.file, "Log file to read.");
|
||||
|
||||
|
@ -255,6 +253,9 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
|
|||
->description("Maximum number of lines to print, starting from the bottom.")
|
||||
->check(CLI::Range(1, std::numeric_limits<int>::max(), "INT > 0"));
|
||||
|
||||
sub->add_flag("--follow", state.log.follow)
|
||||
->description("Keep reading the log until the logging process terminates.");
|
||||
|
||||
sub->add_option("-r,--rules", state.log.readoutRules, "Log file to read.")
|
||||
->description("Rules to apply to the log being read, in the format of QT_LOGGING_RULES.");
|
||||
|
||||
|
@ -267,6 +268,7 @@ int runCommand(int argc, char** argv, QCoreApplication* coreApplication) {
|
|||
|
||||
{
|
||||
auto* sub = cli.add_subcommand("list", "List running quickshell instances.");
|
||||
|
||||
auto* all = sub->add_flag("-a,--all", state.instance.all)
|
||||
->description("List all instances.\n"
|
||||
"If unspecified, only instances of"
|
||||
|
@ -472,7 +474,14 @@ int readLogFile(CommandState& cmd) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
return qs::log::readEncodedLogs(&file, cmd.log.timestamp, cmd.log.tail, *cmd.log.readoutRules)
|
||||
return qs::log::readEncodedLogs(
|
||||
&file,
|
||||
path,
|
||||
cmd.log.timestamp,
|
||||
cmd.log.tail,
|
||||
cmd.log.follow,
|
||||
*cmd.log.readoutRules
|
||||
)
|
||||
? 0
|
||||
: -1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue