Logging - tmuxp.log

Log utilities for tmuxp.

tmuxp.log.setup_logger(logger=None, level='INFO')[source]

Configure tmuxp’s logging for CLI use.

Can checks for any existing loggers to prevent loading handlers twice.

Return type:

None

Parameters:

logger (Logger) – logger instance for tmuxp

tmuxp.log.set_style(message, stylized, style_before='', style_after='', prefix='', suffix='')[source]

Stylize terminal logging output.

Return type:

str

class tmuxp.log.LogFormatter(color=True, **kwargs)[source]

Bases: Formatter

Format logs for tmuxp.

template(record, stylized=False, **kwargs)[source]

Return the prefix for the log message. Template for Formatter.

Return type:

str

Parameters:

record (logging.LogRecord) – Object passed from logging.Formatter.format().

Returns:

Template for logger message.

Return type:

str

format(record)[source]

Format a log record.

Return type:

str

tmuxp.log.debug_log_template(self, record, stylized=False, **kwargs)[source]

Return the prefix for the log message. Template for Formatter.

Return type:

str

Parameters:

record (logging.LogRecord) – Object passed from logging.Formatter.format().

Returns:

Log template.

Return type:

str

class tmuxp.log.DebugLogFormatter(color=True, **kwargs)[source]

Bases: LogFormatter

Provides greater technical details than standard log Formatter.

template(record, stylized=False, **kwargs)[source]

Return the prefix for the log message. Template for Formatter.

Return type:

str

Parameters:

record (logging.LogRecord) – Object passed from logging.Formatter.format().

Returns:

Log template.

Return type:

str

tmuxp.log.tmuxp_echo(message=None, log_level='INFO', style_log=False)[source]

Combine logging.log and print for CLI output.

Return type:

None

Parameters:
  • message (str | None) – Message to log and print. If None, does nothing.

  • log_level (str) – Log level to use (DEBUG, INFO, WARNING, ERROR, CRITICAL). Default is INFO.

  • style_log (bool) – If True, preserve ANSI styling in log output. If False, strip ANSI codes from log output. Default is False.

Examples

>>> tmuxp_echo("Session loaded")
Session loaded
>>> tmuxp_echo("Warning message", log_level="WARNING")
Warning message