Skip to content

octoprint.util.dev#

This module provides a bunch of utility methods and helpers FOR DEVELOPMENT ONLY.

duration_log(context = None, log = None) #

Context manager to log the duration of the wrapped code block.

If no log function is provided will use a debug python logger for octoprint.util.dev.

context can be set to give some textual context in the output.

Parameters:

  • context (str) –

    A custom string to give some textual context in the output.

  • log (callable) –

    The log function to use to log the execution duration.

log_duration(log = None, with_args = False) #

Decorator that logs the execution duration of the annotated function.

Parameters:

  • log (callable) –

    The logging function to use.

  • with_args (bool) –

    Whether to include the calling arguments in the logged output or not.