Skip to main content

Developer-friendly logging helpers for Azure Functions Python

Project description

Azure Functions Logging

PyPI Python Version CI Release Security Scans codecov pre-commit Docs License: MIT

Read this in: 한국어 | 日本語 | 简体中文

Developer-friendly logging helpers for the Azure Functions Python v2 programming model.

Why Use It

Azure Functions Python handlers share the same logging pain points:

  • log output is visually dense and hard to scan
  • errors do not stand out from info-level noise
  • default formatting is not optimized for human readability

azure-functions-logging provides colorized, cleanly formatted log output that works with Python's standard logging module and requires minimal setup.

Scope

  • Azure Functions Python v2 programming model
  • Python's standard logging module
  • Colorized and JSON log output
  • Invocation context injection and cold start detection

This package does not target distributed tracing, log aggregation, or OpenTelemetry integration.

Features

  • Colorized log levels (DEBUG gray, INFO blue, WARNING yellow, ERROR red, CRITICAL bold red)
  • JSON structured log output for production and CI environments
  • Clean [TIME] [LEVEL] [LOGGER] message format
  • setup_logging() one-liner configuration
  • get_logger(__name__) helper for convenient logger creation
  • Automatic invocation context injection (invocation_id, function_name, trace_id)
  • Cold start detection without manual instrumentation
  • Context binding via logger.bind(user_id="abc")
  • host.json log level conflict warning
  • Exception-friendly output with readable stack traces
  • Compatible with Python's standard logging module

Installation

pip install azure-functions-logging

For local development:

git clone https://github.com/yeongseon/azure-functions-logging.git
cd azure-functions-logging
pip install -e .[dev]

Quick Start

from azure_functions_logging import get_logger, setup_logging

setup_logging()

logger = get_logger(__name__)
logger.info("Processing request")

JSON Output

setup_logging(format="json")

logger = get_logger(__name__)
logger.info("Processing request")
# {"timestamp": "...", "level": "INFO", "logger": "...", "message": "Processing request", ...}

Context Injection

from azure_functions_logging import inject_context

def my_function(req, context):
    inject_context(context)
    logger.info("Handling request")  # includes invocation_id, function_name, trace_id

Context Binding

bound = logger.bind(user_id="abc", operation="checkout")
bound.info("Processing")  # includes user_id + operation in every log line

Documentation

Ecosystem

Disclaimer

This project is an independent community project and is not affiliated with, endorsed by, or maintained by Microsoft.

Azure and Azure Functions are trademarks of Microsoft Corporation.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azure_functions_logging-0.2.2.tar.gz (64.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

azure_functions_logging-0.2.2-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file azure_functions_logging-0.2.2.tar.gz.

File metadata

  • Download URL: azure_functions_logging-0.2.2.tar.gz
  • Upload date:
  • Size: 64.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for azure_functions_logging-0.2.2.tar.gz
Algorithm Hash digest
SHA256 e1f860c288a2d8e5e4ed1fcf1fbab92ff294c03e3b795764cad71bd86853b27f
MD5 0cba6e2d330203168e5e12419a8999e0
BLAKE2b-256 fa482a6b737f571e6605d484dd9c888b81dca67c1af53d909b687ef2354cd70a

See more details on using hashes here.

Provenance

The following attestation bundles were made for azure_functions_logging-0.2.2.tar.gz:

Publisher: release.yml on yeongseon/azure-functions-logging

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file azure_functions_logging-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for azure_functions_logging-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 04851e652e53f150b6b47277effd90907bce06cae39809bada5ddb3ce33c877b
MD5 2c59444585d0441e49fc6908698371b3
BLAKE2b-256 ccb782a9519cbbceef37c5d790edc426989eadb8c08285785b0c5dd6f45cc11f

See more details on using hashes here.

Provenance

The following attestation bundles were made for azure_functions_logging-0.2.2-py3-none-any.whl:

Publisher: release.yml on yeongseon/azure-functions-logging

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page