Configuration and logging move out of the context source

context.cpp had grown to hold three unrelated concerns: the context
lifecycle, everything about the .conf file format, and everything about
writing a log message.

conf.cpp now owns the format end to end - parsing a file into the store,
reading values back out, and interpreting a configured string as the
boolean or log level a setting holds. logging.cpp owns the write path:
the level filter, the stream choice, and the name a level carries in
output.

context.cpp keeps what a context is: resolving each setting from the
override, the configured value, or the built-in default, and reporting
what it resolved.
This commit is contained in:
2026-08-18 02:57:47 -04:00
parent 50b95fb729
commit c71913ded9
7 changed files with 429 additions and 283 deletions

View File

@@ -64,7 +64,7 @@ namespace {
* @param name The level name (case-insensitive)
* @return The DPM_LOG_* level, or -1 if unrecognized
*/
int level_from_name(const char* name) {
int log_level_str2enum(const char* name) {
if (strcasecmp(name, "FATAL") == 0) { return DPM_LOG_FATAL; }
if (strcasecmp(name, "ERROR") == 0) { return DPM_LOG_ERROR; }
if (strcasecmp(name, "WARN") == 0) { return DPM_LOG_WARN; }
@@ -202,7 +202,7 @@ int main(int argc, char** argv) {
} else if (option_matches(arg, "-L", "--log-level", &inline_value)) {
const char* v = take_value();
if (!v) { return 1; }
int level = level_from_name(v);
int level = log_level_str2enum(v);
if (level < 0) {
std::fprintf(stderr,
"dpm: unknown log level '%s' (use FATAL, ERROR, "