summaryrefslogtreecommitdiffhomepage
path: root/types/logger
AgeCommit message (Collapse)AuthorFilesLines
2025-04-28types/logger: release ArgWriter destination after useJames Tucker1-0/+1
Spotted after Brad showed me this utility in #15806. Updates #cleanup Signed-off-by: James Tucker <james@tailscale.com>
2025-04-08all: unify some redundant testing.TB interface copiesBrad Fitzpatrick1-7/+2
I added yet another one in 6d117d64a256234 but that new one is at the best place int he dependency graph and has the best name, so let's use that one for everything possible. types/lazy can't use it for circular dependency reasons, so unexport that copy at least. Updates #cleanup Change-Id: I25db6b6a0d81dbb8e89a0a9080c7f15cbf7aa770 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-04-02types/logger, logpolicy: disable rate limiting, don't upload on Plan 9Brad Fitzpatrick1-0/+5
To ease local debugging and have fewer moving pieces while bringing up Plan 9 support. Updates #5794 Change-Id: I2dc98e73bbb0d4d4730dc47203efc0550a0ac0a0 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-04-16all: use Go 1.22 range-over-intBrad Fitzpatrick1-2/+2
Updates #11058 Change-Id: I35e7ef9b90e83cac04ca93fd964ad00ed5b48430 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-03-07cmd/derper, types/logger: move log filter to shared packageAndrew Dunham2-0/+43
So we can use it in trunkd to quiet down the logs there. Updates #5563 Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: Ie3177dc33f5ad103db832aab5a3e0e4f128f973f
2024-01-16all: make use of ctxkey everywhere (#10846)Joe Tsai1-8/+12
Also perform minor cleanups on the ctxkey package itself. Provide guidance on when to use ctxkey.Key[T] over ctxkey.New. Also, allow for interface kinds because the value wrapping trick also happens to fix edge cases with interfaces in Go. Updates #cleanup Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2023-08-30types/logger: add TestLoggerBrad Fitzpatrick1-0/+16
We have this in another repo and I wanted it here too. Updates #cleanup Change-Id: If93dc73f11eaaada5024acf2a885a153b88db5a0 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-30adjust build tags for tamagoAndrea Barisani2-2/+2
Signed-off-by: Andrea Barisani <andrea@inversepath.com>
2023-08-28types/logger: fix test failure I missed earlierBrad Fitzpatrick1-0/+7
I didn't see the race builder fail on CI earlier in 590c693b9. This fixes the test. Updates #greenci Change-Id: I9f271bfadfc29b010226b55bf6647f35f03730b1 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-28types/logger: add AsJSONBrad Fitzpatrick2-0/+50
Printing out JSON representation things in log output is pretty common. Updates #cleanup Change-Id: Ife2d2e321a18e6e1185efa8b699a23061ac5e5a4 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-08-24types/logger, cmd/tailscale/cli: flesh out, simplify some non-unix build tagsBrad Fitzpatrick2-2/+2
Can write "wasm" instead of js || wasi1p, since there's only two: $ go tool dist list | grep wasm js/wasm wasip1/wasm Plus, if GOOS=wasip2 is added later, we're already set. Updates #5794 Change-Id: Ifcfb187c3775c17c9141bc721512dc4577ac4434 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-06-11all: adjust some build tags for wasiBrad Fitzpatrick2-2/+2
A start. Updates #8320 Change-Id: I64057f977be51ba63ce635c56d67de7ecec415d1 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-01-31ipn/ipnlocal: rate-limit diagnose logs in bugreportAndrew Dunham1-0/+47
We can log too quickly for logtail to catch up, even when we opt out of log rate-limiting. When the user passes the --diagnose flag to bugreport, we use a token bucket to control how many logs per second are printed and sleep until we're able to write more. Signed-off-by: Andrew Dunham <andrew@du.nham.ca> Change-Id: If27672d66b621b589280bd0fe228de367ffcbd8f
2023-01-27all: update copyright and license headersWill Norris6-18/+12
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
2022-11-04all: remove old +build tagsBrad Fitzpatrick2-2/+0
The //go:build syntax was introduced in Go 1.17: https://go.dev/doc/go1.17#build-lines gofmt has kept the +build and go:build lines in sync since then, but enough time has passed. Time to remove them. Done with: perl -i -npe 's,^// \+build.*\n,,' $(git grep -l -F '+build') Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-09-29all: fix spelling mistakesJosh Soref1-1/+1
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-09-26doctor: add package for running in-depth healthchecks; use in bugreport (#5413)Andrew Dunham1-0/+2
Change-Id: Iaa4e5b021a545447f319cfe8b3da2bd3e5e5782b Signed-off-by: Andrew Dunham <andrew@du.nham.ca>
2022-09-15refactor: move from io/ioutil to io and os packagesEng Zer Jun1-2/+1
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Reference: https://golang.org/doc/go1.16#ioutil Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-09-15envknob: support changing envknobs post-initBrad Fitzpatrick1-3/+1
Updates #5114 Change-Id: Ia423fc7486e1b3f3180a26308278be0086fae49b Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-08-28logger: migrate rusage syscall use to x/sys/unixNahum Shalman1-3/+4
This will be helpful for illumos (#697) and should be safe everywhere else. Signed-off-by: Nahum Shalman <nahamu@gmail.com>
2022-08-02all: gofmt for Go 1.19Brad Fitzpatrick1-4/+5
Updates #5210 Change-Id: Ib02cd5e43d0a8db60c1f09755a8ac7b140b670be Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-04-05tailcfg: add omitempty to all fields of Hostinfo (#4360)Joe Tsai1-1/+1
This reduces the noise when marshaling only a subset of this type. Signed-off-by: Joe Tsai <joetsai@digital-static.net>
2022-03-17all: use any instead of interface{}Josh Bleecher Snyder3-14/+14
My favorite part of generics. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2022-02-18types/logger: add more reserved top level field namesJosh Bleecher Snyder1-2/+2
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2022-02-18types/logger, logtail: add mechanism to do structured JSON logsBrad Fitzpatrick2-0/+56
e.g. the change to ipnlocal in this commit ultimately logs out: {"logtail":{"client_time":"2022-02-17T20:40:30.511381153-08:00","server_time":"2022-02-18T04:40:31.057771504Z"},"type":"Hostinfo","val":{"GoArch":"amd64","Hostname":"tsdev","IPNVersion":"1.21.0-date.20220107","OS":"linux","OSVersion":"Debian 11.2 (bullseye); kernel=5.10.0-10-amd64"},"v":1} Change-Id: I668646b19aeae4a2fed05170d7b279456829c844 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-01-24envknob: add new package for all the strconv.ParseBool(os.Getenv(..))Brad Fitzpatrick1-2/+3
A new package can also later record/report which knobs are checked and set. It also makes the code cleaner & easier to grep for env knobs. Change-Id: Id8a123ab7539f1fadbd27e0cbeac79c2e4f09751 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-11-30types/logger: add Context and related helpersJosh Bleecher Snyder2-0/+51
We often need both a log function and a context. We can do this by adding the log function as a context value. This commit adds helper glue to make that easy. It is designed to allow incremental adoption. Updates tailscale/corp#3138 Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-10-20all: fix some js/wasm compilation issuesBrad Fitzpatrick2-2/+5
Change-Id: I05a3a4835e225a1e413ec3540a7c7e4a2d477084 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-08-05all: gofmt with Go 1.17Josh Bleecher Snyder1-0/+1
This adds "//go:build" lines and tidies up existing "// +build" lines. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-06-25types/logger: fix deadlock RateLimitedFn reentrancyBrad Fitzpatrick2-5/+21
Fix regression from 19c3e6cc9e9c8371f2aea1c8a19fe1e455038b0b which made the locking coarser. Found while debugging #2245, which ended up looking like a tswin/Windows issue where Crawshaw had blocked cmd.exe's output. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-05-05types/logger: add key grinder stats lines to rate-limiting exemption listJosh Bleecher Snyder1-2/+6
Updates #1749 Co-authored-by: Brad Fitzpatrick <bradfitz@tailscale.com> Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-05-04types/logger: fix rate limiter allowlistJosh Bleecher Snyder1-1/+1
Upstream wireguard-go renamed the interface method from CreateEndpoint to ParseEndpoint. I updated the log call site but not the allowlist. Signed-off-by: Josh Bleecher Snyder <josharian@gmail.com>
2021-04-30types/logger: rate limited: more hysteresis, better messages.Avery Pennarun3-39/+142
- Switch to our own simpler token bucket, since x/time/rate is missing necessary stuff (can't provide your own time func; can't check the current bucket contents) and it's overkill anyway. - Add tests that actually include advancing time. - Don't remove the rate limit on a message until there's enough room to print at least two more of them. When we do, we'll also print how many we dropped, as a contextual reminder that some were previously lost. (This is more like how the Linux kernel does it.) - Reformat the [RATE LIMITED] messages to be shorter, and to not corrupt original message. Instead, we print the message, then print its format string. - Use %q instead of \"%s\", for more accurate parsing later, if the format string contained quotes. Fixes #1772 Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2021-01-28types/logger: fix rateFree interaction with verbosity prefixesJosh Bleecher Snyder1-4/+4
We log lines like this: c.logf("[v1] magicsock: disco: %v->%v (%v, %v) sent %v", c.discoShort, dstDisco.ShortString(), dstKey.ShortString(), derpStr(dst.String()), disco.MessageSummary(m)) The leading [v1] causes it to get unintentionally rate limited. Until we have a proper fix, work around it. Fixes #1216 Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-01-19types/logger: trim spaces from the rate-limited example message.David Anderson1-1/+1
Signed-off-by: David Anderson <danderson@tailscale.com>
2021-01-15wgengine/magicsock: close test loggers once we're done with themJosh Bleecher Snyder1-0/+24
This is a big hammer approach to helping with #1132. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-01-13Provide example when format string is rate limitedSmitty2-3/+3
Here's an example log line in the new format: [RATE LIMITED] format string "open-conn-track: timeout opening %v; no associated peer node" (example: "open-conn-track: timeout opening ([ip] => [ip]); no associated peer node") This should make debugging logging issues a bit easier, and give more context as to why something was rate limited. This change was proposed in a comment on #1110. Signed-off-by: Smitty <me@smitop.com>
2021-01-08wgengine: quiet some wireguard-go loggingJosh Bleecher Snyder1-0/+13
The log lines that wireguard-go prints as it starts and stops its worker routines are mostly noise. They also happen after other work is completed, which causes failures in some of the log testing packages. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2020-12-19Clarify that raw format strings are intentionalSmitty2-3/+3
This caused some confusion in issue #460, since usually raw format strings aren't printed directly. Hopefully by directly logging that they are intended to be raw format strings, this will be more clear. Rate limited format strings now look like: [RATE LIMITED] format string "control: sendStatus: %s: %v" Closes #460. Signed-off-by: Smitty <me@smitop.com>
2020-11-11all: prepare for GOOS=ios in Go 1.16Brad Fitzpatrick1-1/+1
Work with either way for now on iOS (darwin/arm64 vs ios/arm64). In February when Go 1.16 comes out we'll have a universal binary for darwin/arm64 (macOS) and will drop support for Go 1.15 and its darwin/amd64 meaning iOS. (it'll mean macOS). Context: * https://tip.golang.org/doc/go1.16#darwin * https://github.com/golang/go/issues/38485 * https://github.com/golang/go/issues/42100
2020-10-29types/logger: fix LogOnChange to pass through format/args to underlying loggerBrad Fitzpatrick1-1/+4
So they don't get interpretted as a format pattern or get rate-limited away in the wrong way.
2020-10-19types/logger: move RusagePrefixLog to logger package, disable by defaultBrad Fitzpatrick3-0/+63
The RusagePrefixLog is rarely useful, hasn't been useful in a long time, is rarely the measurement we need, and is pretty spammy (and syscall-heavy). Disable it by default. We can enable it when we're debugging memory.
2020-07-14types/logger: fix go test vet errorElias Naur1-1/+1
Silences types/logger/logger_test.go:63:30: conversion from int to string yields a string of one rune Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-07-03types/logger: add rateFreePrefix rate-limiting-exempt log format prefixesBrad Fitzpatrick1-0/+14
Per conversation with @danderson.
2020-06-15Fix concurrency issues in controlclient, ipn, types/logger (#456)Dmytro Shynkevych2-1/+35
Signed-Off-By: Dmytro Shynkevych <dmytro@tailscale.com>
2020-05-29types/logger: add TS_DEBUG_LOG_RATE knob to easily turn off rate limitingBrad Fitzpatrick1-0/+6
2020-05-20log rate limiting: reformat limiter messages, and use nonempty burst size.Avery Pennarun2-8/+10
- Reformat the warning about a message being rate limited to print the format string, rather than the formatted message. This helps give a clue what "type" of message is being limited. - Change the rate limit warning to be [RATE LIMITED] in all caps. This uses less space on each line, plus is more noticeable. - In tailscaled, change the frequency to be less often (once every 5 seconds per format string) but to allow bursts of up to 5 messages. This greatly reduces the number of messages that are rate limited during startup, but allows us to tighten the limit even further during normal runtime. Signed-off-by: Avery Pennarun <apenwarr@tailscale.com>
2020-05-15wgengine: log node IDs when peers are added/removed (#381)Wendi Yu2-18/+80
Also stop logging data sent/received from nodes we're not connected to (ie all those `x`s being logged in the `peers: ` line) Signed-off-by: Wendi <wendi.yu@yahoo.ca>
2020-05-13types/logger: add ArgWriterBrad Fitzpatrick2-0/+31
2020-05-11types/logger: simplify mutex locking in rate-limited loggerBrad Fitzpatrick1-31/+42
Updates #365 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>