FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects

Resolve "Fastapi logging setup"

Merged E. Evstafiev requested to merge 6-add-fastapi-logging-setup into main

Closes #6 (closed)

Merge request reports

Pipeline #519178 passed with warnings

Pipeline passed with warnings for 161f6bdc on 6-add-fastapi-logging-setup

Test coverage 91.00% (3.00%) from 3 jobs

Merged by E. KirkE. Kirk 9 months ago (May 7, 2024 11:09am UTC)

Loading

Pipeline #520910 passed with warnings

Pipeline passed with warnings for f54f46c8 on main

Test coverage 91.00% (3.00%) from 3 jobs

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • 1 import structlog
    2
    3 from .gunicorn_conf import configure_logging
    4
    5 configure_logging()
    • Comment on lines +3 to +5

      We need to move the common logging configuration out of the gunicorn specific module

    • E. Evstafiev changed this line in version 6 of the diff

      changed this line in version 6 of the diff

    • Author Maintainer

      The current logging setup does indeed function as intended, as demonstrated in this branch.

      Or you meant about decoupling the common logging setup from the gunicorn-specific module, something like this:

      import abc
      import structlog
      
      class LoggingConfigurator(abc.ABC):
          @abc.abstractmethod
          def configure(self):
              pass
      ...
      class GunicornLoggingConfigurator(LoggingConfigurator):
          def configure(self):
              # Gunicorn-specific logging configuration
      ...
      class FastAPILoggingConfigurator(LoggingConfigurator):
          def configure(self):
              # FastAPI-specific logging configuration
      ...
      class LoggingConfigurationFactory:
          @staticmethod
          def get_configurator(environment: str) -> LoggingConfigurator:
              if environment == "gunicorn":
                  return GunicornLoggingConfigurator()
              elif environment == "fastapi":
                  return FastAPILoggingConfigurator()
              else:
                  raise ValueError("Unsupported environment for logging configuration")
      ...
      configurator = LoggingConfigurationFactory.get_configurator("fastapi")
      configurator.configure()
    • Please register or sign in to reply
  • Just need to rejig things a bit

  • E. Kirk changed target branch from main to 2_gunicorn_conf_mechanism

    changed target branch from main to 2_gunicorn_conf_mechanism

  • Peter Keen deleted the 2_gunicorn_conf_mechanism branch. This merge request now targets the main branch

    deleted the 2_gunicorn_conf_mechanism branch. This merge request now targets the main branch

  • E. Kirk
  • E. Evstafiev added 2 commits

    added 2 commits

    • f89af578 - review: refactor logging system and bump version to 0.1.0
    • 7db80ac7 - fix isort formatting

    Compare with previous version

  • E. Evstafiev added 14 commits

    added 14 commits

    Compare with previous version

  • E. Evstafiev added 1 commit

    added 1 commit

    • 161f6bdc - refactor: move common logging configuration

    Compare with previous version

  • E. Evstafiev requested review from @ee345

    requested review from @ee345

  • E. Evstafiev requested review from @ek599 and removed review request for @ee345

    requested review from @ek599 and removed review request for @ee345

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading