Get logging configuration
get_logging_config.Rd
Retrieves logging settings from the main configuration list. Provides sensible defaults if settings are not specified.
Arguments
- config
The main configuration list, typically loaded from a YAML file via
load_config()
.
Value
A list with logging configuration:
enabled
: Logical, TRUE if logging is enabled, FALSE otherwise.path
: Character, the directory path for storing logs. Defaults to "rydra_logs" if enabled but no path is specified. Is NULL if logging is disabled.
Examples
if (FALSE) { # \dontrun{
# Example using a manually created config list
dummy_config_no_logging <- list(model_name = "test")
settings1 <- get_logging_config(dummy_config_no_logging)
print(paste("Logging enabled:", settings1$enabled)) # Should be FALSE
dummy_config_with_logging <- list(
model_name = "test",
logging = list(enabled = TRUE, path = "my_app_logs")
)
settings2 <- get_logging_config(dummy_config_with_logging)
if (settings2$enabled) {
print(paste("Logging enabled, path:", settings2$path))
}
# Example with package's example_config.yaml
config_path <- system.file("extdata", "example_config.yaml", package = "Rydra")
if (config_path == "" && file.exists("inst/extdata/example_config.yaml")) {
config_path <- "inst/extdata/example_config.yaml" # Fallback for dev
}
if (file.exists(config_path)) {
actual_config <- load_config(config_path)
log_settings_from_file <- get_logging_config(actual_config)
print(paste("Logging from file enabled:", log_settings_from_file$enabled))
if (log_settings_from_file$enabled) {
print(paste("Logging path from file:", log_settings_from_file$path))
}
} else {
print("Could not find example_config.yaml for get_logging_config example.")
}
} # }