configure_logging

pymseed.configure_logging(log_prefix=None, error_prefix=None, max_messages=10)[source]

Configure libmseed logging for the current thread.

This function can be called from any thread to configure its logging parameters. Each threading.Thread can hold its own log prefixes and message registry; calls from different threads do not interfere.

The arguments are also remembered as the configuration for threads that never call this function themselves; pymseed applies it to each thread on first use, so message capture works on any thread without setup.

Per-thread isolation requires libmseed to be built with thread-local storage (the default — see logging.c lm_thread_local selection). When libmseed is built with LIBMSEED_NO_THREADING defined, all threads share a single global log registry and the last configure_logging() call wins process-wide.

Parameters:
  • log_prefix (str | None) – Prefix for log messages. None leaves the current prefix in place (libmseed’s default if none has been set); pass "" to remove a prefix that was set earlier.

  • error_prefix (str | None) – Prefix for error messages, as for log_prefix. libmseed’s default is "Error: ".

  • max_messages (int) – Maximum number of warning/error messages to store in message registry. When the registry is full, oldest messages are discarded. A value of 0 disables the registry.

Raises:
  • TypeError – If a prefix is neither a str nor None.

  • ValueError – If max_messages is negative.

Return type:

None

Example

>>> from pymseed import configure_logging
>>> configure_logging(log_prefix="[LOG] ", error_prefix="[ERR] ")