mirror of
https://github.com/NixOS/nix.git
synced 2025-11-29 05:31:00 +01:00
Add Setting<std::filesystem::path> specialization
Like PathSetting, this normalizes the path (without resolving symlinks).
This commit is contained in:
parent
487c6b6c46
commit
93c51acfb5
4 changed files with 17 additions and 3 deletions
|
|
@ -433,6 +433,18 @@ std::string BaseSetting<StringMap>::to_string() const
|
||||||
[](const auto & kvpair) { return kvpair.first + "=" + kvpair.second; });
|
[](const auto & kvpair) { return kvpair.first + "=" + kvpair.second; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
std::filesystem::path BaseSetting<std::filesystem::path>::parse(const std::string & str) const
|
||||||
|
{
|
||||||
|
return std::filesystem::path(str).lexically_normal();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
std::string BaseSetting<std::filesystem::path>::to_string() const
|
||||||
|
{
|
||||||
|
return value.string();
|
||||||
|
}
|
||||||
|
|
||||||
template class BaseSetting<int>;
|
template class BaseSetting<int>;
|
||||||
template class BaseSetting<unsigned int>;
|
template class BaseSetting<unsigned int>;
|
||||||
template class BaseSetting<long>;
|
template class BaseSetting<long>;
|
||||||
|
|
@ -445,6 +457,7 @@ template class BaseSetting<Strings>;
|
||||||
template class BaseSetting<StringSet>;
|
template class BaseSetting<StringSet>;
|
||||||
template class BaseSetting<StringMap>;
|
template class BaseSetting<StringMap>;
|
||||||
template class BaseSetting<std::set<ExperimentalFeature>>;
|
template class BaseSetting<std::set<ExperimentalFeature>>;
|
||||||
|
template class BaseSetting<std::filesystem::path>;
|
||||||
|
|
||||||
static Path parsePath(const AbstractSetting & s, const std::string & str)
|
static Path parsePath(const AbstractSetting & s, const std::string & str)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ DECLARE_CONFIG_SERIALISER(Strings)
|
||||||
DECLARE_CONFIG_SERIALISER(StringSet)
|
DECLARE_CONFIG_SERIALISER(StringSet)
|
||||||
DECLARE_CONFIG_SERIALISER(StringMap)
|
DECLARE_CONFIG_SERIALISER(StringMap)
|
||||||
DECLARE_CONFIG_SERIALISER(std::set<ExperimentalFeature>)
|
DECLARE_CONFIG_SERIALISER(std::set<ExperimentalFeature>)
|
||||||
|
DECLARE_CONFIG_SERIALISER(std::filesystem::path)
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T BaseSetting<T>::parse(const std::string & str) const
|
T BaseSetting<T>::parse(const std::string & str) const
|
||||||
|
|
|
||||||
|
|
@ -54,9 +54,9 @@ struct LoggerSettings : Config
|
||||||
expression evaluation errors.
|
expression evaluation errors.
|
||||||
)"};
|
)"};
|
||||||
|
|
||||||
Setting<Path> jsonLogPath{
|
Setting<std::filesystem::path> jsonLogPath{
|
||||||
this,
|
this,
|
||||||
"",
|
{},
|
||||||
"json-log-path",
|
"json-log-path",
|
||||||
R"(
|
R"(
|
||||||
A file or unix socket to which JSON records of Nix's log output are
|
A file or unix socket to which JSON records of Nix's log output are
|
||||||
|
|
|
||||||
|
|
@ -370,7 +370,7 @@ void applyJSONLogger()
|
||||||
if (!loggerSettings.jsonLogPath.get().empty()) {
|
if (!loggerSettings.jsonLogPath.get().empty()) {
|
||||||
try {
|
try {
|
||||||
std::vector<std::unique_ptr<Logger>> loggers;
|
std::vector<std::unique_ptr<Logger>> loggers;
|
||||||
loggers.push_back(makeJSONLogger(std::filesystem::path(loggerSettings.jsonLogPath.get()), false));
|
loggers.push_back(makeJSONLogger(loggerSettings.jsonLogPath.get(), false));
|
||||||
try {
|
try {
|
||||||
logger = makeTeeLogger(std::move(logger), std::move(loggers));
|
logger = makeTeeLogger(std::move(logger), std::move(loggers));
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue