summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Aehlig <klaus.aehlig@huawei.com>2024-04-10 12:01:54 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2024-04-10 16:18:07 +0200
commitaafd97ee263f11da108b873ed8f350f3824f9f67 (patch)
tree9b2a475f7022527e109e078bc4d2cf65dddc79dc
parent7034d65c652e6cf5d66e7f17787f359f304d2637 (diff)
downloadjustbuild-aafd97ee263f11da108b873ed8f350f3824f9f67.tar.gz
Support stderr log-limit restriciton for serve
As `just serve` is used like a daemon it can be desirable to restrict stderr, e.g., to only errors, while keeping a detailled log of the activity in a file.
-rw-r--r--share/man/just-serve-config.5.md6
-rw-r--r--src/buildtool/main/serve.cpp17
2 files changed, 20 insertions, 3 deletions
diff --git a/share/man/just-serve-config.5.md b/share/man/just-serve-config.5.md
index 0612b181..4f127ea4 100644
--- a/share/man/just-serve-config.5.md
+++ b/share/man/just-serve-config.5.md
@@ -31,11 +31,11 @@ The configuration file is given by a JSON object.
- The value for the key *`"logging"`* is a JSON object specifying logging
options.
For subkey *`"files"`* the value is a list of strings specifying one or more
- local log files to use. The files will store the information printed on
- stderr, along with the thread id and timestamp when the output has been
- generated.
+ local log files to use.
For subkey *`"limit"`* the value is an integer setting the default for
the log limit.
+ For subkey *`"restrict stderr limit"`* the value is an integer setting a
+ restriction for the log on stderr.
For subkey *`"plain"`* the value is a flag. If set, do not use ANSI escape
sequences to highlight messages.
For subkey *`"append"`* the value is a flag. If set, append messages to log
diff --git a/src/buildtool/main/serve.cpp b/src/buildtool/main/serve.cpp
index 9dc4d936..1c321c0b 100644
--- a/src/buildtool/main/serve.cpp
+++ b/src/buildtool/main/serve.cpp
@@ -239,6 +239,23 @@ void ReadJustServeConfig(gsl::not_null<CommandLineArguments*> const& clargs) {
}
clargs->log.log_limit = ToLogLevel(limit->Number());
}
+ // read stderr restriction
+ auto stderr_limit =
+ logging->Get("restrict stderr limit", Expression::none_t{});
+ if (stderr_limit.IsNotNull()) {
+ if (not stderr_limit->IsNumber()) {
+ Logger::Log(
+ LogLevel::Error,
+ "In serve service config file {}:\nValue for logging key "
+ "\"restrict stderr limit\" has to be numeric, but found {}",
+ clargs->serve.config.string(),
+ limit->ToString());
+ std::exit(kExitFailure);
+ }
+ clargs->log.restrict_stderr_log_limit =
+ ToLogLevel(stderr_limit->Number());
+ }
+ // read stderr restriction
}
// read client TLS authentication arguments
auto auth_args = serve_config["authentication"];