Structured logging to journald - #2969
Draft
darkexplosiveqwx wants to merge 26 commits into
Draft
Conversation
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
We never read from FTL.log and webserver.log after opening them, so +read is unnecessary. Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
darkexplosiveqwx
force-pushed
the
log-journal
branch
from
July 26, 2026 08:49
98971ad to
13547b5
Compare
|
Conflicts have been resolved. |
carries to: FIFO, webserver.log changes webserver.log format (again) Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
adresses review: - `log_web()` now takes `(priority, flag, ...)` and most call sites pass `DEBUG_NONE`. Since `log_web_debug()` is already a macro, a matching convenience macro for the plain info/error case would drop `DEBUG_NONE` from those call sites and read cleaner. It is only a handful of sites, so this is readability rather than diff size. Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
The static variable process was set by init_FTL_log() but never read anywhere in the codebase - it was dead code since its introduction in 8f40798 (2021). Removing it also eliminates the name parameter which is no longer needed. Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
this would be duplicated with log_web(LOG_INFO, "Initializing HTTP server on ports \"%s\"", config.webserver.port.v.s); Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
darkexplosiveqwx
force-pushed
the
log-journal
branch
from
July 26, 2026 09:15
13547b5 to
3b06c28
Compare
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Code Review: And FTLCONF_files_log_ftl="" is skipped by getLogFilePathENV() but accepted by the regular load, which is a small inconsistency. Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
| // held, so writes to different files never contend. The reopen flag is | ||
| // per-file so SIGUSR2 only touches the fd that actually needs it. | ||
| static bool write_log_line(struct log_fd *log, const char *line, size_t len) | ||
| { |
|
|
||
| void init_FTL_log(const char *name) | ||
| // Open cached log fds from config paths. | ||
| // open_log_fds(true): open FTL.log only (called early, before full config) |
Code Review: On the fallback, the direction is right but the snippet has two problems. First, the comparison is inverted: syslog priorities ascend as severity drops (LOG_CRIT 2 < LOG_ERR 3 < LOG_WARNING 4 < LOG_INFO 6), so priority >= LOG_WARNING catches WARNING/NOTICE/INFO/DEBUG and skips exactly the ERROR and CRIT lines we are trying to save. It needs to be priority <= LOG_WARNING. Second, config.files.log.webserver.v.s == NULL will practically never be true: the default is /var/log/pihole/webserver.log, initConfig() always seeds v from d, and we have no empty-means-disabled handling for that key (unlike files.pcap, which uses validate_filepath_empty). Setting files.log.webserver = "" passes validate_webserver_logfile() and then simply fails in fopen(). So the case that actually loses messages is the open failing - empty path, unwritable directory, read-only filesystem - and there we currently drop the line in daemon mode without even the syslog fallback that _FTL_log() has. Please gate on weblog == NULL instead, and rather than duplicating the formatting, just hand the already-formatted buffer over _log_web() does not honour print_log/print_stdout outside CLI mode, so log_ctrl(false, false) (e.g., src/api/action.c:49) no longer silences everything, and it never prints to stdout in non-daemon mode - so pihole-FTL -f no longer shows the relocated errors on the console the way log_err() did. Routing through _FTL_log() as above fixes the second half for free. Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Code Review: Two things are still open from my second point, all in src/webserver/webserver.c: the OOM sites (lines 64, 73, 82, 91, 100, 360, 506, 665, 715, 814, 836, 948) and the startup failures - 619 Not starting web server as webserver.port is empty, 652 Initializing HTTP library failed!, 658 Failed to build web paths ... and the whole mg_start2() failure block at 871-874. Those are process-health signals: "web interface will not be available" is what someone greps FTL.log for. Line 874 also became circular - we now write "Hint: Check the webserver log at ..." into the webserver log. Worth noting that a bad files.log.webserver is itself a plausible reason for that block to run, and then all four lines disappear in daemon mode, i.e., no web interface and nothing in the logs. Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
the embedded dnsmasq already does a fd cleanup on startup, so this is not strictly necessary, but still good practice Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
https://discourse.pi-hole.net/t/something-on-my-network-trying-to-contact-zoom/86982/11 is too funny, had to do it Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
TID= is specified for use in man:systemd.journal-fields(7) Signed-off-by: darkexplosiveqwx <101737077+darkexplosiveqwx@users.noreply.github.com>
darkexplosiveqwx
force-pushed
the
log-journal
branch
from
July 30, 2026 19:42
3b06c28 to
7929ce9
Compare
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thank you for your contribution to the Pi-hole Community!
Please read the comments below to help us consider your Pull Request.
We are all volunteers and completing the process outlined will help us review your commits quicker.
Please make sure you
What does this PR aim to accomplish?:
Discussed in #2897
Stacked on top of #2958, #2960 and #2968
Requires pi-hole/docker-base-images#175 to build.
How does this PR accomplish the above?:
Link documentation PRs if any are needed to support this PR:
By submitting this pull request, I confirm the following:
git rebase)