Google Sign-In Required

Use your company Google account to access the BetterFleet private content.

Back to private home

BetterFleet Support Private
Skip to content
BetterFleet Dev Wiki
0016 - Logging & log levels
Initializing search
    bf-dev
    • Home
    • Product Capabilities
    • Process
    • Current Work
    • System Design
    • Software Reference
    • Operations
    bf-dev
    • Home
      • Overview
      • Manage
      • Overview
      • Product Engineering Workflow
      • Product Engineering Delivery
      • Product Engineering Workflow in Linear
        • GitLab Feature Flags
        • In-App Docs Authoring
        • Release Notes
      • Templates
      • Publishing
      • Workflow Companions
      • Overview
      • Active Artifacts
      • Backlog Artifacts
      • Archived Artifacts
      • Overview
      • Microgrid
      • OSCP
        • Challenge
        • Specification
        • Spec
        • Architecture
        • Overview
        • Script Runtime Model
        • Compose Profiles and Modes
        • Repo Topology
        • CI and Release Integration
        • Overview
        • Internal Application Diagrams
          • Overview
          • Web Model
          • Core Model
        • Service Interaction Flows
        • Data and State
          • Index
          • bf-manage-web
          • bf-manage-core
          • bf-manage-connect
          • bf-manage-sitepwrmon
          • bf-manage-incidents
          • bf-telematics
          • bf-depot-sim
          • bf-manage-roaming
          • bf-support-microsite
          • bf-digital-twin
          • bf-schedule-creator
        • Overview
        • Internal Application Diagrams
        • Migration and Flags
        • Simulation Request Lifecycle
          • Index
          • bf-bnl-ui
          • bf-bnl-settings
          • bf-bnl-schedule-analysis-compute
          • bf-route-modelling
          • bf-schedule-creator
          • bf-digital-twin
        • Overview
        • Secrets and Env Strategy
        • Vendors and Local Dependencies
        • ADRs
        • Service Matrix
        • Cloud Dependencies
        • Ports and URLs
      • Onboarding
      • Daily Operations Runbook
        • Overview
        • Staging Hotfix Release
        • Production Hotfix Release
        • Terraform Plan Dry Runs
      • Troubleshooting
      • Testing Guide
    • Date
    • Status
    • Context
    • Decision
    • Consequences

    0016 - Logging & log levels¶

    Date¶

    2024-01-16

    Status¶

    Proposed

    Context¶

    In our Python applications, we need a consistent and effective way to log various events and errors. Logging levels help in categorising the severity and type of logs, which in turn aids in monitoring and troubleshooting.

    Decision¶

    We will use the following logging levels in our Python applications: * CRITICAL: Used when a critical error occurs, and the application cannot recover from it. This level is for events that require immediate attention, and the likelihood of the application recovering on its own is close to zero. Examples include system outages, critical data corruption, failing authorizations to external services, resources at maximum capacity for extended periods, or security breaches. Critical logs will trigger alerts, which are currently SNS emails forwarded to Slack. * ERROR: Used for significant issues in which the application has encountered a problem but may still continue running. The odds of recovery are high, or the failure might be an expected outcome. Errors do not trigger alerts but are logged for investigation. Examples include failed transactions, missing data in non-critical paths, or unexpected states.

    Additionally, if a result is processed from an external service and there is a catch all (example: except Exception as e) then this should be logged as an error.

    • WARNING: For situations that are not errors but could potentially be harmful or indicative of an impending issue. Warnings do not indicate a failure but are logged for awareness and potential future action. A typical scenario is when an endpoint returns a 404 response, and the existence of the entity is is uncertain, or when an exception is caught, but the code path still returns a value (even if empty).
    • INFO: Used for general operational messages that track the normal functioning of the application. These logs are helpful for understanding the flow of the application and include events such as service startup, shutdown, routine operations, or configuration changes.
    • DEBUG: The most granular logging level, intended for detailed diagnostic information useful during development or deep troubleshooting. This includes internal state, intermediate values, SQL queries, loop progress, and other low-level details that would be too noisy for normal production logs.

    Consequences¶

    • More consistent logs across services and developers.
    • Better filtering and alerting because log intent is more explicit.
    • Some judgement is still required, especially around deciding when a warning should instead be treated as an error or critical issue.
    Made with Material for MkDocs