Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Add a helper function for systemd's SyslogLevelPrefix

Open
#249 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #829 by @Solaris-star — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

Start by reading the existing add_log_level_number processor and the linked Python SysLogHandler and python-systemd level mappings. Then identify how processors can add a syslog level to event_dict and how PrintLogger formats the event; the issue leaves the message-prefix behavior open. Done means the level mapping and the chosen prefixing approach are implemented and covered by tests.

Written by the indexing model from the issue text.

Description

waiting for feedback

From systemd.exec(5):

SyslogLevelPrefix=

Takes a boolean argument. If true and StandardOutput= or StandardError= are set to syslog, kmsg or journal, log lines written by the executed process that are prefixed with a log level will be passed on to syslog with this log level set but the prefix removed. If set to false, the interpretation of these prefixes is disabled and the logged lines are passed on as-is. For details about this prefixing see sd-daemon(3). Defaults to true.

i.e. for the simple case where a service emits output to stdout, and systemd picks that up, it may be helpful to add a prefix with the syslog log level. systemd will also pick that up, strip it from its output, and use it as the log level, by default.

There are two parts to this:

  1. Adding the syslog log level to event_dict, i.e. "4" (or syslog.LOG_WARNING) for "warn"/"warning", etc. Python's logging.handlers.SysLogHandler has code for that, and python-systemd is trying to do something more clever to cover custom log levels. Neither are reusable, but should be simple to implement. It should be similar to the existing add_log_level_number processor.
  2. A simple processor that prepends the event message with said level. I'm guessing that will be more controversial though. Alternatively, it could also be an argument to PrintLogger.

The "syslog" log level will also be useful in case one e.g. wants to write a processor using the stdlib syslog module (i.e. without involving logging).

Dominant language
Python
Stars
5k
Forks
302
Avg merge
17m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hynek/structlog

All issues in hynek/structlog

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.