Files
test/doc/source/framework/logging/index.rst
Andrew Vaillancourt 0839bbf183 Add logging framework docs
- Document structured test step logging and logging best practices
- Explain log source tagging (AUT, TST, SSH, EXC, etc.)
- Add section on LogExceptionFilter and LogNonExceptionFilter
- Update framework/index.rst to include logging in toctree

Change-Id: Iadc88c706760e1f5d38707827410eac893853a47
Signed-off-by: Andrew Vaillancourt <andrew.vaillancourt@windriver.com>
2025-04-03 22:19:52 -04:00

2.6 KiB
Raw Blame History

framework/logging/ Documentation

The framework/logging/ directory provides centralized logging for the StarlingX Test Automation Framework. It standardizes log format, sources, and behavior across keywords, test cases, and framework utilities.

Contents

Overview

Logging is handled via a singleton instance of AutomationLogger, which wraps Python's logging module but adds:

  • Structured test step logging
  • Automatic source tagging (e.g., AUT, TST, SSH)
  • Support for per-test logs and exception filtering
  • CLI + file output with unified formatting

Accessing the Logger

Always use:

from framework.logging.automation_logger import get_logger
get_logger().log_info("My log message")

This ensures:

  • You dont manually instantiate or manage loggers.
  • All logs use the centralized format and handler structure.
  • Logging behavior (formatting, filtering, file output) is consistent.

Logging Conventions

Log messages are tagged with a source code:

  • AUT General automation logs
  • TST Structured test steps
  • SSH SSH commands and output
  • KEY Keyword-level trace logs
  • EXC Exception logs (stack traces)
  • LIB 3rd-party logs

Framework Methods

The following methods are available:

Method Description Source
log_info() Log a general message AUT
log_debug() Log a debug message AUT
log_warning() Log a warning AUT
log_error() Log a non-exception error AUT
log_exception() Log an exception (no stack trace duplication) EXC
log_keyword() Auto-logged when keyword wrappers are used KEY
log_ssh() Logs SSH commands sent and received SSH
log_test_case_step() Structured, numbered test steps TST

Structured Test Step Logging

Use log_test_case_step() to structure your test case flow:

get_logger().log_test_case_step("Lock the host")
get_logger().log_test_case_step("Assign label foo=bar")
get_logger().log_test_case_step("Verify label is assigned")

This automatically prints:

Test Step 1: Lock the host
Test Step 2: Assign label foo=bar
Test Step 3: Verify label is assigned

Step numbers are reset between tests using `