Skip to content

feat(landing): Python logging levels guide - #1574

Merged
JeremyFunk merged 9 commits into
mainfrom
feat/guide-python-logging-levels
Oct 31, 2026
Merged

JeremyFunk merged 9 commits into
mainfrom
feat/guide-python-logging-levels

Conversation

@JeremyFunk

@JeremyFunk JeremyFunk commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Adds /guides/python-logging-levels, a beginner-first explainer and how-to for the levels in Python's standard logging module.

Covers

  • Basics: what a log level is, the five levels (DEBUG, INFO, WARNING, ERROR, CRITICAL) with a plain sentence and an example call each, setting the level with basicConfig and setLevel, why log.info() prints nothing by default (WARNING), and a question list for choosing a level. Levels use the named constants only, no numeric values.
  • Setting the level from a --log-level flag or a LOG_LEVEL variable (tabs), the basicConfig runs-once callout (one sentence plus the setLevel fix), and quieting noisy libraries with per-logger levels.
  • One short section on logger vs handler levels (terminal at WARNING, file at DEBUG).
  • OpenTelemetry, self-contained: what you get (Python logs with their level sent to any OTLP backend), the install command, a complete logs-only telemetry.py (endpoint, auth header, service name, a terminal handler for every level and a LoggingHandler at INFO on the root logger), how to run it with real output, and what you see on Maple's Logs page (two screenshots). Maple is the example backend; a local OpenTelemetry Collector endpoint is given as the alternative.
  • Four common mistakes and an FAQ.

Level colors use the --severity-* tokens that Maple's Logs page uses, in the badges, tables and code. Every code block has a copy button (bindCopyButtons from src/lib/copy-to-clipboard.ts, as in the Loguru guide); output blocks don't.

Shared code (additive)

  • LanguageTabs takes an optional group storage key, so this page's tabs don't overwrite the language a reader picked elsewhere on the site.
  • guide-highlight.ts: a console mode for terminal sessions and more Python keywords.

Also fixes content/docs/guides/instrumentation-python.md. Once telemetry.py has attached its handler, basicConfig(level=...) does nothing, so the docs now say to call logging.getLogger().setLevel(...) and link to this guide.

Search intent: what the Python logging levels are, the default level, and how to set the level in code, from the command line or from an environment variable.

Maple docs linked: /docs/explore/logs, and /docs/guides/instrumentation-python from the closing card only (for traces and metrics).

Verification: every Python snippet on the page was run on Python 3.14.5 and the sample outputs are from those runs. The telemetry.py and app.py pair was run with opentelemetry-sdk 1.45.1, opentelemetry-exporter-otlp-proto-http 1.45.1 and opentelemetry-instrumentation-logging 0.66b1 against a local OTLP/HTTP receiver: the terminal shows all three lines, the receiver gets the INFO and WARNING records with the service name and auth header, and without the urllib3 line the exporter's DEBUG request logs print. bun run --cwd apps/landing build passes; the page was reviewed in Playwright at desktop and mobile widths.

Sources: Python docs (logging, Logging HOWTO), the OTLP specification and PyPI opentelemetry-instrumentation-logging.

Summary by CodeRabbit

  • New Features

    • Added a comprehensive guide explaining Python logging levels, configuration, filtering, and OpenTelemetry integration.
    • Added the Python logging guide to the guides index and generated guide listing.
    • Improved code examples with Python keyword and console-session syntax highlighting.
    • Language tabs can now use custom grouping keys.
  • Documentation

    • Clarified how to configure the root logger when using telemetry handlers.

@maple-review-bot

This comment has been minimized.

@maple-review-bot maple-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 inline note from Maple's review. The score and summary are in the review comment above.

<p class="guide-kicker">Python logs in Maple</p>
<h3>Search by severity, then jump to the trace</h3>
<p>
Once the handler is attached, the Logs page charts volume by severity, filters by service and environment, and opens the trace behind any line logged inside a span. Using Loguru instead? See the <a href="/guides/loguru">Loguru guide</a>.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Link to /guides/loguru has no page in this repository

F1 · Warning · correctness

/guides/loguru resolves to no page: apps/landing/src/pages/guides/ holds only api-latency, index, python-logging-levels, uptime-monitoring, what-is-apdex and what-is-apm, on this head and on main. Every other internal guide link points at an existing page, so this one sends readers to the 404 page unless the parallel Loguru PR lands first.

Hold this sentence until `apps/landing/src/pages/guides/loguru.astro` exists, or point it at `/docs/guides/instrumentation-python#logging` until then.
🤖 Prompt to fix with an AI agent
In `apps/landing/src/pages/guides/python-logging-levels.astro:541`: Link to `/guides/loguru` has no page in this repository.

`/guides/loguru` resolves to no page: `apps/landing/src/pages/guides/` holds only api-latency, index, python-logging-levels, uptime-monitoring, what-is-apdex and what-is-apm, on this head and on `main`. Every other internal guide link points at an existing page, so this one sends readers to the 404 page unless the parallel Loguru PR lands first.

Suggested fix: Hold this sentence until `apps/landing/src/pages/guides/loguru.astro` exists, or point it at `/docs/guides/instrumentation-python#logging` until then.

Verify the problem exists at that location before changing it, and keep the fix to those lines.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional: /guides/loguru is being added in a parallel PR. Merge that one first (or together) so the link resolves.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

console.setFormatter(logging.Formatter("%(levelname)-8s %(name)s: %(message)s"))
root.addHandler(console)

root.addHandler(LoggingHandler(level=logging.INFO, logger_provider=logger_provider))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Debug logs leak and exports duplicate

When added after the Python telemetry setup, otelCode exports DEBUG records to Maple and exports INFO records twice. The existing root LoggingHandler remains at NOTSET alongside the new INFO-only handler.

Learn more

The Python instrumentation setup already attaches a LoggingHandler to the root logger at NOTSET in telemetry.py. This example is labeled as code to run after that setup creates logger_provider. Raising the root logger to DEBUG lets its existing handler receive DEBUG records. Appending a second handler at INFO leaves the first intact, so INFO and higher records go to Maple twice.

Example: After importing telemetry, run this snippet and emit log.debug("cart has 3 items") followed by log.info("order 1042 placed"). Maple receives one DEBUG record and two INFO records instead of zero DEBUG and one INFO.

Recommended fix: Replace or reconfigure the existing telemetry LoggingHandler rather than appending another one. For example, keep a reference to the existing handler in telemetry.py and set its level to INFO before raising the root level, then add only the console handler.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the snippet now replaces the line in telemetry.py that adds the LoggingHandler, so the root logger has a single OpenTelemetry handler at INFO.

@maple-review-bot

This comment has been minimized.

@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

We couldn't safely recover the incremental review. No full review was started, and the last reviewed checkpoint was preserved. Retry later, or explicitly request a full review by commenting @coderabbitai full review.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7716e62d-b196-44b8-af07-4be86617f4d8
📥 Commits

Reviewing files that changed from the base of the PR and between e71f8b9 and 87bd710.

📒 Files selected for processing: 8
  • apps/landing/public/screenshots/guides/python-logging-levels-01-severity-filter.webp
  • apps/landing/public/screenshots/guides/python-logging-levels-02-log-detail.webp
  • apps/landing/src/components/docs/LanguageTabs.astro
  • apps/landing/src/content/docs/guides/instrumentation-python.md
  • apps/landing/src/lib/guide-highlight.ts
  • apps/landing/src/pages/guides/index.astro
  • apps/landing/src/pages/guides/python-logging-levels.astro
  • apps/landing/src/pages/llms.txt.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 0 remain after this review.

Walkthrough

Adds a Python logging levels guide with code examples, OpenTelemetry and Maple guidance, and guide listings. Updates Python and console syntax highlighting, clarifies root logger configuration in the instrumentation guide, and adds configurable language tab groups.

Changes: Python Logging Guide

Layer / File(s) Summary
Guide code highlighting
apps/landing/src/lib/guide-highlight.ts
Adds console-session highlighting and recognizes additional Python keywords.
Logging concepts and configuration
apps/landing/src/pages/guides/python-logging-levels.astro, apps/landing/src/content/docs/guides/instrumentation-python.md
Adds the guide’s page structure, logging concepts, and configuration examples. Updates the instrumentation guidance to set the root logger level explicitly.
OpenTelemetry integration and presentation
apps/landing/src/pages/guides/python-logging-levels.astro
Adds OpenTelemetry and Maple guidance, common mistakes, FAQs, and responsive styles.
Guide listings
apps/landing/src/pages/guides/index.astro, apps/landing/src/pages/llms.txt.ts
Adds the Python logging guide to the guides index and generated Guides listing.

Language Tab Groups

Layer / File(s) Summary
Configurable tab-group key
apps/landing/src/components/docs/LanguageTabs.astro
Adds an optional group prop, defaults it to maple-docs-language, and uses it for the root data-lang-tabs attribute.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Suggested reviewers: makisuo

Merge Risk: Minimal · previous review 87bd7

This adds a documentation guide and small supporting component changes. The only caveat is that the /guides/loguru link should land together with, or after, its parallel PR; otherwise it will lead to a 404.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely identifies the main change: adding a Python logging levels guide to the landing site.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (4 skipped: 4 unsupported.)

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@JeremyFunk
JeremyFunk force-pushed the feat/guide-python-logging-levels branch from 275d763 to ee07df5 Compare October 20, 2026 16:38
@maple-review-bot

This comment has been minimized.

@maple-review-bot maple-review-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 inline note from Maple's review. The score and summary are in the review comment above.

@maple-review-bot

This comment has been minimized.

Covers the standard levels, logger vs handler levels and propagation, setting the level from argparse, LOG_LEVEL and dictConfig, per-module levels, custom levels and getLevelNamesMapping, and how levels interact with the OpenTelemetry LoggingHandler. Fixes the Python instrumentation doc, which suggested basicConfig after the handler is attached, where it is a no-op.
Short H1, five grouped sections, a diagram of how a record passes the
logger level, propagates and meets each handler's level, level colors
shared with Maple's severity palette, and highlighted code throughout.
The ways to set the level sit in tabs; the OpenTelemetry section uses the
LoggingHandler from opentelemetry-instrumentation-logging.

LanguageTabs takes an optional storage group so non-language tabs don't
overwrite the remembered language. The guide highlighter gains a console
mode and more Python keywords.
Lead with what a level is, the five levels with an example each and how
basicConfig sets one. Drop the numeric values, dictConfig, the -v flag,
runtime switching and the propagation diagram; keep handler levels as one
short section before OpenTelemetry.
@JeremyFunk
JeremyFunk force-pushed the feat/guide-python-logging-levels branch from 87bd710 to 16961c2 Compare October 22, 2026 18:44
@maple-review-bot

This comment has been minimized.

…ng levels guide

The OpenTelemetry section now installs, configures and runs a complete
logs-only telemetry.py for any OTLP backend, with Maple as the example.
Drop the severity mapping, shorten the basicConfig callout and add copy
buttons to every code block.
@maple-review-bot

This comment has been minimized.

…ging-levels

# Conflicts:
#	apps/landing/src/lib/guide-highlight.ts
#	apps/landing/src/pages/guides/index.astro
#	apps/landing/src/pages/llms.txt.ts
@maple-review-bot

This comment has been minimized.

@maple-review-bot

maple-review-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Maple review

🟡 Confidence 6/10 · needs attention. Held at 6 because a correctness warning is open.
1 warning −1 · tests missing −2 · risk medium · 1 defect fixed in earlier rounds

Adds the Python logging levels guide, new console/python-logging/loguru-output highlighter modes and a LanguageTabs storage-key prop; the snippets and token usage check out. Still open: the earlier /guides/loguru link, which 404s until the parallel guide merges.

  • highlight gains console, python-logging, loguru-output, nrql, shell, json, javascript modes
  • LanguageTabs takes a group prop as the tab storage key
  • New /guides/python-logging-levels page, listed on /guides and in llms.txt
  • instrumentation-python.md now says to call setLevel instead of basicConfig after the telemetry handler

Before merge

Still open from earlier reviews

3e7c5ed · What was checked, coverage and telemetry details are on the Maple / review check. Reply "won't fix" to dismiss a finding, or mention @maple-review-bot to ask about one.

@JeremyFunk
JeremyFunk merged commit c27964a into main Oct 31, 2026
28 checks passed
@JeremyFunk
JeremyFunk deleted the feat/guide-python-logging-levels branch October 31, 2026 10:46
@maple-review-bot

Copy link
Copy Markdown

Merged with 2 steps from "Before merge" still open. If they are done, tick them on the review comment; if not, now is the time.

  • Env var · Set LOG_LEVEL in every environment, or confirm its default
  • Manual · Merge the /guides/loguru guide with or before this one so the link at line 470 resolves

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant