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