Skip to content

This is useful for avoiding computation when logging is inactive.

Usage

is_logging_enabled(severity = "info", logger = NULL)

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().

Value

TRUE is OpenTelemetry logging is active, FALSE otherwise.

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)
  }
  # ...
}