The default slog handlers are quite configurable.
Overview
…
Both TextHandler and JSONHandler can be configured with HandlerOptions. There are options for setting the minimum level (see Levels, below), displaying the source file and line of the log call, and modifying attributes before they are logged.
While HandlerOptions only exposes three fields:
AddSource boolLevel LevelerReplaceAttr func(groups []string, a Attr) Attr
The last one provides an immense amount of flexibility, letting you filter, replace, or augment log key/value pairs as they are processed. This lets you do things like filter out sensitive or noisy log information, or add additional details to errors, etc.
That said, the option you’re most likely to use the most is the simpler Level field. This lets you set the level for the handler—only want ERROR or higher logs to go to a particular place? This is where you control that.
And AddSource instructs the handler to compute the source code position of the log statement and add a SourceKey attribute to the output.