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.Threadcan 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.clm_thread_localselection). When libmseed is built withLIBMSEED_NO_THREADINGdefined, all threads share a single global log registry and the lastconfigure_logging()call wins process-wide.- Parameters:
log_prefix (str | None) – Prefix for log messages.
Noneleaves 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_messagesis negative.
- Return type:
None
Example
>>> from pymseed import configure_logging >>> configure_logging(log_prefix="[LOG] ", error_prefix="[ERR] ")