Skip to content

feat: LoggingPlugin for asserting log output #5

@elijahr

Description

@elijahr

Summary

Add a LoggingPlugin that intercepts logging.Logger calls and records them as assertable interactions.

Motivation

Asserting that code emits the right log messages at the right levels is a very common testing need. Currently there's no bigfoot plugin for this. Test authors either use caplog (pytest) with manual assertions that lack bigfoot's certainty guarantees, or don't assert logs at all.

Proposed Design

  • Intercepts logging.Logger.log, info, warning, error, critical, debug
  • Records interactions with fields: level, message, logger_name
  • Simple state machine: one step per log call
  • Assertion helpers: assert_log(level, message, logger_name) or per-level helpers like assert_warning(message)
  • No extra dependencies (stdlib only)
  • Proxy: bigfoot.log_mock

Why it fits bigfoot

Logging is a side effect of code execution. bigfoot's model is "every external call intercepted, queued, and verified." Log calls are external calls to the logging subsystem that can and should be verified with the same certainty guarantees as HTTP calls or database queries.

Acceptance Criteria

  • LoggingPlugin with assert_log() and per-level assertion helpers
  • Full assertion certainty (all fields required)
  • Guide in mkdocs docs
  • API reference page
  • README section

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions