Defines where to document rsyslog coding practices and how to structure pattern and antipattern entries for the core and close sibling libraries such as liblognorm.
rsyslog coding practices reference¶
Purpose and scope¶
This page is the canonical home for rsyslog good coding practices. Use it to record patterns and antipatterns that help humans and AI reason about the code base. Its scope covers:
The rsyslog core and built-in modules.
Closely related libraries that share design DNA (for example,
liblognorm).Links to external per-library practice documents when they exist.
Referencing from sibling libraries¶
When a closely related library such as liblognorm needs to reuse this
guidance:
Point to this page as the canonical source from the sibling project’s docs, release notes, or development guide (for example, a
coding-practicesentry in itsdevelopmentorcontributingindex).Add a brief subsection in this page for the library with anchors that match the name used in its own docs so deep links stay stable.
If the sibling project maintains extra practices, mirror the entry format and provide a link back here so readers can pivot between shared and library-specific rules.
Keep cross-repo links stable by using the published rsyslog docs URL or the raw file link when referencing this page from other repositories.
Entry format¶
Capture each practice (pattern or antipattern) in a consistent shape to make it machine- and human-friendly:
Title and anchor:
.. _practice-name:plus a short, action-oriented heading.Classification:
PatternorAntipattern.Context: The subsystem (for example, queueing, parsers, outputs, test harness) and any relevant modules.
Why it matters: Risks avoided or benefits gained when following the practice.
Steps: Checklist-style guidance that can be turned into linting or code review prompts.
References: Pointers to implementation examples, tests, or design docs.
Organizing topics¶
Group practices by the areas reviewers and tools check most often:
Concurrency and state: Worker isolation, per-action locks, and avoiding WID leakage.
Memory and ownership: Allocation conventions, lifetime rules, and cleanup expectations around action data and modules.
Error handling and logging: Uniform error paths, return-code handling, and structured logging expectations.
Configuration and templates: RainerScript guidance, template reuse, and validation hooks.
External dependencies: How to guard optional libraries such as
liblognormand how to document minimum supported versions.
Contribution workflow¶
Use the steps below when adding or updating a practice entry:
Choose the best section above or create a new subsection with a clear anchor.
Add a
PatternorAntipatternlabel and fill in the context, why, and steps bullets so they can be enforced by reviews and automated checks.Link to concrete examples (source files, tests, or commit IDs) to ground the guidance.
Mention related guidance in sibling libraries (for example, link to a
liblognormrule) so maintainers can keep the documents in sync.When practices change behavior, note migration tips for existing modules and call out any CI or linting hooks that should be updated.
Practice catalog¶
Individual patterns and antipatterns live in their own files for easier retrieval by humans and RAG pipelines. They are collected here via a short toctree so navigation remains discoverable from the development guide.
AI agent integration¶
AI assistants (including prompt-driven doc builders or code generators) should consume this page when preparing change plans or reviews:
Add the
coding_practicespage to any retrieval or “context seeding” step that feeds AI agents, alongside module metadata and per-directoryAGENTS.mdguidance.Prefer deep links to specific practice anchors when citing expectations in generated plans, RAG snippets, or review comments.
When patterns are updated, refresh downstream prompts (for example, commit helpers or doc-builder base prompts) so they keep injecting the latest practices.
Discoverability and expected pickup¶
The page is wired into the default AI workflow so it is easy to pull into context:
The repository-level
AGENTS.mdpoints todoc/AGENTS.mdas the first stop for documentation work, and that guide explicitly calls outcoding_practices.rstas mandatory RAG seed material.The page lives in the
developmenttoctree so Sphinx navigation and search surface it from the rendered docs even without AGENTS links.The doc-builder base prompt (
ai/rsyslog_code_doc_builder/base_prompt.txt) tells agents to load this page before writing or revising guidance.Given those hooks, an agent that follows the documented prompt chain has a high likelihood (roughly 85–95%) of loading and honoring this guidance; risk primarily comes from prompts that ignore the AGENTS chain or operate on a partial checkout without the
doc/tree.
Adaptation for sibling libraries¶
For libraries like liblognorm, keep a minimal subsection here with
library-specific anchors and point to the canonical document in that repository.
Mirror the entry format so AI tools can learn a single schema while respecting
per-library details.
Support: rsyslog Assistant | GitHub Discussions | GitHub Issues: rsyslog source project
Contributing: Source & docs: rsyslog source project
© 2008–2025 Rainer Gerhards and others. Licensed under the Apache License 2.0.