This is useful for avoiding computation when logging is inactive.
is_logging_enabled(severity = "info", logger = NULL)Check if logs are emitted at this severity level.
Logger object (otel_logger), or a logger name, the
instrumentation scope, to pass to get_logger().
TRUE is OpenTelemetry logging is active, FALSE otherwise.
It calls get_logger() with name and then it calls the logger's
$is_enabled() method.
Other OpenTelemetry logs API:
log(),
log_severity_levels
fun <- function() {
if (otel::is_logging_enabled()) {
xattr <- calculate_some_extra_attributes()
otel::log("Starting fun", attributes = xattr)
}
# ...
}