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 module. Use this for status messages generated by TAU Commander.
- sys.stdout via
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: str
-
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: str
-
class
taucmdr.logger.LogFormatter(line_width, printable_only=False, allow_colors=True)[source]¶ Bases:
logging.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
-
format(record)[source]¶ Formats a log record.
Parameters: record (LogRecord) – LogRecord instance to format. Returns: The formatted record message. Return type: str Raises: RuntimeError– No format specified for a the record’s logging level.
-
taucmdr.logger.TERM_SIZE= (80, 25)¶ (width, height) tuple of detected terminal dimensions in characters.
Type: tuple
-
taucmdr.logger._get_term_size_env()[source]¶ Discover the size of the user’s terminal via environment variables.
The user may set the LINES and COLUMNS environment variables to control TAU Commander’s console dimension calculations.
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: tuple
-
taucmdr.logger._get_term_size_posix()[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: tuple
-
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: tuple
-
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: tuple
-
taucmdr.logger._prune_ansi(line)[source]¶ Remove all occurrences of the ANSI escape sequence
Returns: Line where all ‘[*m’ sequences were removed Return type: str
-
taucmdr.logger.get_logger(name)[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()[source]¶ Discover the size of the user’s terminal.
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: tuple
