module documentation

Logging utilities for Dulwich.

Any module that uses logging needs to do compile-time initialization to set up the logging environment. Since Dulwich is also used as a library, clients may not want to see any logging output. In that case, we need to use a special handler to suppress spurious warnings like "No handlers could be found for logger dulwich.foo".

For details on the _NullHandler approach, see: http://docs.python.org/library/logging.html#configuring-logging-for-a-library

For many modules, the only function from the logging module they need is getLogger; this module exports that function for convenience. If a calling module needs something else, it can import the standard logging module directly.

Function default_logging_config Set up the default Dulwich loggers.
Function remove_null_handler Remove the null handler from the Dulwich loggers.
Class _NullHandler No-op logging handler to avoid unexpected logging warnings.
Function _configure_logging_from_trace Configure logging based on GIT_TRACE environment variable.
Function _configure_packet_trace Configure packet tracing based on GIT_TRACE_PACKET environment variable.
Function _get_trace_target Get the trace target from GIT_TRACE environment variable.
Function _should_trace Check if GIT_TRACE is enabled.
Constant _DULWICH_LOGGER Undocumented
Constant _NULL_HANDLER Undocumented
def default_logging_config():

Set up the default Dulwich loggers.

Respects the GIT_TRACE environment variable for trace output: - If GIT_TRACE is set to "1", "2", or "true", trace to stderr - If GIT_TRACE is set to an integer 3-9, trace to that file descriptor - If GIT_TRACE is set to an absolute path, trace to that file - If the path is a directory, trace to files in that directory (per process) - Otherwise, use default stderr output

def remove_null_handler():

Remove the null handler from the Dulwich loggers.

If a caller wants to set up logging using something other than default_logging_config, calling this function first is a minor optimization to avoid the overhead of using the _NullHandler.

def _configure_logging_from_trace() -> bool:

Configure logging based on GIT_TRACE environment variable.

Returns True if trace configuration was successful, False otherwise.

def _configure_packet_trace() -> bool:

Configure packet tracing based on GIT_TRACE_PACKET environment variable.

Returns True if packet trace configuration was successful, False otherwise.

def _get_trace_target() -> str | int | None:

Get the trace target from GIT_TRACE environment variable.

Returns
str | int | None
  • None if tracing is disabled
  • 2 for stderr output (values "1", "2", "true")
  • int (3-9) for file descriptor
  • str for file path (absolute paths or directories)
def _should_trace() -> bool:

Check if GIT_TRACE is enabled.

Returns True if tracing should be enabled, False otherwise.

_DULWICH_LOGGER =

Undocumented

Value
getLogger('dulwich')
_NULL_HANDLER =

Undocumented

Value
_NullHandler()