taucmdr.logger module¶
TAU Commander logging.
- TAU Commander has two channels for communicating with the user:
sys.stdout via
print. Use this for messages the user has requested, e.g. a project listing.sys.stdout and sys.stderr via
taucmdr.logger. Use this for status messages generated by TAU Commander.
TAU Commander also logs all status messages at the highest reporting level to a rotating debug file in the user’s TAU Commander project prefix, typically “~/.taucmdr”.
- taucmdr.logger.LINE_WIDTH = 74¶
Width of a line on the terminal.
Uses system specific methods to determine console line width. If the line width cannot be determined, the default is 80.
- taucmdr.logger.LOG_FILE = '/home/runner/.local/taucmdr/debug_log'¶
Absolute path to a log file to receive all debugging output.
- Type:
- taucmdr.logger.LOG_LEVEL = 'INFO'¶
The global logging level for stdout loggers and software packages.
Don’t change directly. May be changed via
set_log_level.- Type:
- class taucmdr.logger.LogFormatter(line_width: int, printable_only: bool = False, allow_colors: bool = True)[source]¶
Bases:
FormatterCustom log message formatter.
Controls message formatting for all levels.
- Parameters:
line_width (int) – Maximum length of a message line before line is wrapped.
printable_only (bool) – If True, never send unprintable characters to
sys.stdout.
- _colored(text, *color_args)[source]¶
Insert ANSII color formatting via termcolor.
- Text colors:
grey
red
green
yellow
blue
magenta
cyan
white
- Text highlights:
on_grey
on_red
on_green
on_yellow
on_blue
on_magenta
on_cyan
on_white
- \* bold
- \* dark
- \* underline
- \* blink
- \* reverse
- \* concealed
- _printable_chars = {'\t', '\n', '\x0b', '\x0c', '\r', ' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', '*', '+', ',', '-', '.', '/', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '{', '|', '}', '~'}¶
- taucmdr.logger.TERM_SIZE = (80, 25)¶
(width, height) tuple of detected terminal dimensions in characters.
- Type:
- taucmdr.logger._get_term_size_env() Tuple[int | None, int | None][source]¶
Discover the size of the user’s terminal via environment variables.
The user may set the COLUMNS and LINES environment variables to control TAU Commander’s console dimension calculations.
- Returns:
- (width, height) tuple from COLUMNS and LINES, with None for a variable
that is unset or not an integer.
- Return type:
- taucmdr.logger._get_term_size_posix() Tuple[int, int] | None[source]¶
Discover the size of the user’s terminal on a POSIX operating system (e.g. Linux).
- Returns:
- (width, height) tuple giving the dimensions of the user’s terminal window in characters,
or None if the size could not be determined.
- Return type:
- taucmdr.logger._get_term_size_tput()[source]¶
Discover the size of the user’s terminal via tput.
- Returns:
- (width, height) tuple giving the dimensions of the user’s terminal window in characters,
or None if the size could not be determined.
- Return type:
- taucmdr.logger._get_term_size_windows()[source]¶
Discover the size of the user’s terminal on Microsoft Windows.
- Returns:
- (width, height) tuple giving the dimensions of the user’s terminal window in characters,
or None if the size could not be determined.
- Return type:
- taucmdr.logger._prune_ansi(line)[source]¶
Remove all occurrences of the ANSI escape sequence
- Returns:
Line where all
\x1b[*msequences were removed- Return type:
- taucmdr.logger.get_logger(name: str) Logger[source]¶
Returns a customized logging object.
Multiple calls to with the same name will always return a reference to the same Logger object.
- Parameters:
name (str) – Dot-separated hierarchical name for the logger.
- Returns:
An instance of
logging.Logger.- Return type:
Logger
- taucmdr.logger.get_terminal_size() Tuple[int, int][source]¶
Discover the size of the user’s terminal.
The COLUMNS and LINES environment variables set the width and height. Otherwise several methods are attempted depending on the user’s OS. If no method succeeds then default to (80, 25).
- Returns:
(width, height) tuple giving the dimensions of the user’s terminal window in characters.
- Return type: