Skip to content

Commit

Permalink
Suppress tailscaled logs after 200 lines (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmagyar authored Mar 30, 2023
1 parent a3fd6b7 commit 0bbafaf
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
23 changes: 23 additions & 0 deletions tailscale/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ subnets on all supported interfaces to Tailscale.
tags:
- tag:example
- tag:homeassistant
log_level: info
```
### Option: `tags`
Expand All @@ -64,6 +65,28 @@ instance. They need to start with `tag:`.

More information: <https://tailscale.com/kb/1068/acl-tags/>

### Option: `log_level`

Optionally enable tailscaled debug messages in the add-on's log. Turn it on only
in case you are troubleshooting, because Tailscale's daemon is quite chatty.

The `log_level` option controls the level of log output by the addon and can
be changed to be more or less verbose, which might be useful when you are
dealing with an unknown issue. Possible values are:

- `trace`: Show every detail, like all called internal functions.
- `debug`: Shows detailed debug information.
- `info`: Normal (usually) interesting events.
- `notice`: Normal but significant events.
- `warning`: Exceptional occurrences that are not errors.
- `error`: Runtime errors that do not require immediate action.
- `fatal`: Something went terribly wrong. Add-on becomes unusable.

Please note that each level automatically includes log messages from a
more severe level, e.g., `debug` also shows `info` messages. By default,
the `log_level` is set to `info`, which is the recommended setting unless
you are troubleshooting.

## Changelog & Releases

This repository keeps a change log using [GitHub's releases][releases]
Expand Down
1 change: 1 addition & 0 deletions tailscale/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ RUN \
iproute2=6.0.0-r1 \
iptables=1.8.8-r2 \
nginx=1.22.1-r0 \
coreutils=9.1-r0 \
\
&& ln -sf /sbin/xtables-nft-multi /sbin/ip6tables \
&& ln -sf /sbin/xtables-nft-multi /sbin/iptables \
Expand Down
1 change: 1 addition & 0 deletions tailscale/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ devices:
host_network: true
schema:
tags: ["match(^tag:[a-zA-Z0-9]-?[a-zA-Z0-9]+$)?"]
log_level: list(trace|debug|info|notice|warning|error|fatal)?
9 changes: 8 additions & 1 deletion tailscale/rootfs/etc/s6-overlay/s6-rc.d/tailscaled/run
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@ declare -a options
bashio::log.info 'Starting Tailscale...'

options+=(--state=/data/tailscaled.state)
# Opt out of client log upload to log.tailscale.io
options+=(--no-logs-no-support)
options+=(--tun=userspace-networking)

# Run Tailscale
exec /opt/tailscaled "${options[@]}"
if bashio::debug ; then
exec /opt/tailscaled "${options[@]}"
else
bashio::log.notice "Tailscale logs will be suppressed after 200 lines, set add-on's configuration option 'log_level' to 'debug' to see further logs"
/opt/tailscaled "${options[@]}" 2>&1 | stdbuf -i0 -oL -eL sed -n -e '1,200p' -e "201c[further tailscaled logs suppressed, set add-on's configuration option 'log_level' to 'debug' to see further tailscaled logs]"
fi

0 comments on commit 0bbafaf

Please sign in to comment.