Log(WARN) interferes with "--output json". #537

Closed
opened 2025-12-29 02:19:38 +01:00 by adam · 0 comments
Owner

Originally created by @linsomniac on GitHub (Aug 4, 2023).

Why

I'm using 10.* addresses and recently headscale changed to emit a warning about not using 100. addresses. I have some scripts which use "headscale node list --output json", that started failing because this warning was causing the output to not be JSON. I'm thinking that it would be nice if warnings were written to stderr, particularly in the cast of JSON output, so that warnings don't interfere with JSON parsing.

Errors could also go to stderr, but I'm assuming in an error the JSON output will probably be faulty anyway, so it's a slightly different use case (more of a feature request than bug report).

I'm able to fix it by passing the headscale output through an AWK range pattern: awk '/^\[/,/^\]/ { print }'

Description

Change logging output, particular of WRN level, to go to stderr.

Originally created by @linsomniac on GitHub (Aug 4, 2023). ## Why I'm using 10.* addresses and recently headscale changed to emit a warning about not using 100. addresses. I have some scripts which use "headscale node list --output json", that started failing because this warning was causing the output to not be JSON. I'm thinking that it would be nice if warnings were written to stderr, particularly in the cast of JSON output, so that warnings don't interfere with JSON parsing. Errors could also go to stderr, but I'm assuming in an error the JSON output will probably be faulty anyway, so it's a slightly different use case (more of a feature request than bug report). I'm able to fix it by passing the headscale output through an AWK range pattern: `awk '/^\[/,/^\]/ { print }'` ## Description Change logging output, particular of WRN level, to go to stderr.
adam added the enhancement label 2025-12-29 02:19:38 +01:00
adam closed this issue 2025-12-29 02:19:39 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#537