What the agent does
Logrus says in its own README that it is in maintenance mode, and Go has shipped a structured logger, log/slog, since 1.21. The agent begins by counting what the code asks of Logrus. In a tool like jwplayer/buildpipe-buildkite-plugin, three files import it as log: main.go, git.go and pipeline.go. Between them there are five log.Fatalf calls, three log.Debugf, two log.Info, and one log.ParseLevel feeding log.SetLevel from the BUILDKITE_PLUGIN_BUILDPIPE_LOG_LEVEL variable. No hooks, no custom formatter, no WithFields. go.mod declares go 1.13 and pins github.com/sirupsen/logrus v1.5.0.
Two of those uses have no one-line equivalent. slog has no fatal level, and log.Fatalf both logs and exits with status 1, which this plugin relies on: a missing pipeline file has to fail the Buildkite step. The agent adds one small fatal helper that calls slog.Error and then os.Exit(1), and checks the exit code of the built binary with a missing file before and after. The level is the second. logrus.ParseLevel accepts warning, trace, fatal and panic; slog.Level.UnmarshalText accepts debug, info, warn and error in any case and rejects those four. Because main falls back to info on a parse error, a pipeline that sets log_level: warning would start logging at info without any message. The agent maps the old names explicitly so no documented value changes meaning.
It then has to make the build work, and the first attempt shows why. With go 1.13 in go.mod the helper's ...any parameter does not compile: predeclared any requires go1.18 or later. The agent raises the directive to 1.21, the first release with log/slog. The plugin's real test path goes through tests/Dockerfile, which builds with FROM golang:1.14, an image that has no log/slog at all. That line has to move in the same pull request or make test, the only command in .github/workflows/pr.yml, cannot build the binary.
For proof the agent does not need Docker. It runs go vet and go test, builds with CGO_ENABLED=0, and runs the binary the way tests/post-command.bats does: tests/dynamic_pipeline.yml as the pipeline, and two stub scripts on PATH named git and buildkite-agent. It compares standard output of the old and new binaries, which must be identical because that is the generated pipeline, and prints standard error from both. The old line is time="..." level=debug msg="Current branch: not_master"; with a slog.TextHandler on standard error the new one is time=... level=DEBUG msg="current branch" branch=not_master.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "Replace github.com/sirupsen/logrus with the standard library log/slog in this Go command-line tool. Read go.mod, every file that imports logrus, the Makefile, the test Dockerfile and the CI workflow. Count each kind of call: Fatal, Error, Warn, Info, Debug, WithField, ParseLevel, SetLevel, SetFormatter, hooks. Build the unchanged binary first and record its exit code and standard error for a missing config file, and its standard output for the sample pipeline with stub git and buildkite-agent scripts on PATH. Then port: one helper for fatal errors that logs at error level and exits 1, key and value attributes instead of format strings, a TextHandler on standard error so standard output stays clean, and a level parser that accepts every value logrus accepted (including warning, trace, fatal and panic) and maps it to the nearest slog level. Raise the go directive only as far as the build needs and update every Dockerfile or CI file that pins an older Go image. Run go vet, go test and go mod tidy. Build the new binary and repeat the same three checks; standard output must be byte-identical. List every log line whose text or format changed. Do not start Docker; say which checks only CI can run. Open a pull request with every command and its output.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request that edits the three Go files, go.mod, go.sum and tests/Dockerfile. After go mod tidy Logrus is gone from go.mod and only deepcopy, testify and yaml.v2 remain as direct requirements. The description holds the call count, the level table for old and new parsers, the exit code check, a note that standard output of the two binaries matched, and the standard error of both so the format change is visible.
The reviewer looks at what consumes these logs. Anything that greps for level=debug in lower case, or for the old message text, needs the same edit, and the description lists each changed line for that purpose. They also see what the agent could not run: the bats suite goes through docker-compose, so its first real execution is the pull request's own CI. The README still describes log_level as used by a Python script; the agent corrects that sentence only if the prompt asks.
Run it on every Linear issue labelled logging
Logging migrations tend to be filed once per tool and then left. Connect Linear under Settings → Connections and add an automation on the Project with a linear trigger on linear.issue.labeled for the label you choose, with the prompt above saved as its prompt. When someone in your Rush org adds the label, a run starts in the Project's repository with the issue appended after the prompt as event text.
For several tools at once, skip the automation and send this body to POST /o/{org}/sessions once per repository, each with a request_id that is a UUID v5 of the repository name. Runs beyond the key's max_concurrent wait as queued and start as slots free.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
A logger swap looks mechanical and fails in the places nobody greps for: an exit code that disappears with Fatalf, a level name that silently stops parsing, a builder image two major toolchains too old. Each of those is found by building and running the tool, which the agent does in a sandbox that has Go and nothing of yours to break. The commands, the two binaries' output and the exit codes are kept with the run.
The comparison of standard output is the part a person rarely does by hand. This plugin prints the pipeline it uploads, so a stray log line on the wrong stream would corrupt its only product. Showing the two outputs match turns that worry into a checked fact in the pull request.
Frequently asked questions
What replaces log.Fatal in slog?
Nothing built in. slog stops at error level and never exits the process. The usual replacement is a helper that calls slog.Error and then os.Exit(1), which is what the agent adds, or returning the error up to main and exiting there.
Will my log format change?
Yes, in small ways. With slog.TextHandler the level is upper case, the timestamp is unquoted with milliseconds, and values that were formatted into the message become separate keys. If something parses the old lines, tell the agent and it keeps the message text and adds a ReplaceAttr function for the level.
Which Go version does this need?
Go 1.21 or later, where log/slog first appears. The go line in go.mod has to say at least 1.18 for any and should say 1.21, and every build image has to match. In this repository that means the golang:1.14 builder in tests/Dockerfile.
Can I keep Logrus and still use slog?
Yes. A library can log through slog while the application installs a bridge handler that forwards records to Logrus, and the Logrus README names interoperability with log/slog as the kind of change it still accepts. That route keeps your formatter and hooks; the migration above is for tools that use neither.