Skip to content

v0.1.1

Choose a tag to compare

@thephw thephw released this 26 Oct 23:38
a4cf84d

Configurable logging with opt-in structured JSON logs (#21)

  • Every adapter (MemoryAdapter, PostgresAdapter, PosthogAdapter) and PosthogAPIClient takes a logger= argument. It defaults to structlog.get_logger(), so logs follow your application's structlog configuration.
  • feature_gate no longer calls structlog.configure, so creating an adapter no longer replaces your app's structlog config.
  • New feature_gate.structured_logging module for JSON logs:
    • json_logger(file=None): JSON-lines logger (stdout by default) to pass as logger=.
    • PROCESSORS: use with structlog.configure(processors=PROCESSORS) to render your whole app as JSON.
  • See the Logging section of the README.

Breaking changes

  • MemoryAdapter no longer writes ./logs/feature_gate.log, and PosthogAPIClient no longer writes $PROJECT_ROOT/logs/development.log; PROJECT_ROOT is no longer used. To keep a log file, pass logger=json_logger(open("logs/feature_gate.log", "a")).
  • Logs render however your app has configured structlog (structlog's console output if unconfigured) rather than always as JSON.

This is the first release with these changes on PyPI. 0.1.0 was never published there (PyPI blocks that filename from an earlier deleted upload).

Full Changelog: v0.0.9...v0.1.1