pain001.context package#

Submodules#

pain001.context.context module#

Singleton application context that owns the shared pain001 logger.

class pain001.context.context.Context[source]#

Bases: object

A singleton that manages the shared pain001 logger.

Instantiating the class directly raises RuntimeError once the singleton exists; use get_instance() instead.

__init__(self)[source]#

Initializes the class and creates a logger.

get_instance()[source]#

Returns the singleton instance of the class.

get_logger(self)[source]#

Returns the logger.

init_logger(self)[source]#

Initializes the logger.

set_log_level(self, log_level)[source]#

Sets the log level of the logger.

set_name(self, name)[source]#

Sets the name of the logger.

static get_instance() Context[source]#

Returns the singleton instance of the class.

Returns:

A Context instance.

Raises:

RuntimeError – If the singleton failed to initialize (defensive check; unreachable in practice).

get_logger() Logger[source]#

Returns the logger.

Returns:

A Logger instance.

init_logger() None[source]#

Initializes the logger.

Raises:

RuntimeError – If the logger has already been initialized.

instance: Context | None = None#
set_log_level(log_level: int) None[source]#

Sets the log level of the logger.

Parameters:

log_level – The log level of the logger.

Raises:

ValueError – If the log level is invalid.

set_name(name: str) None[source]#

Sets the name of the logger.

Parameters:

name – The name of the logger. Empty names are coerced to “pain001” so the root logger is never claimed.

Module contents#

Application context package for pain001.