Documentation
¶
Overview ¶
Package logging makes the logger gist writes its log file with: JSON lines through log/slog, to a file under the state directory, never to the terminal the TUI draws on.
The logger is made once, in the app package, and passed down. A log line never holds a token, or the content, description or comments of a gist: a gist is named by its ID and a file by its name.
Index ¶
- Constants
- func DefaultPath() string
- func Discard() *slog.Logger
- func Follow(ctx context.Context, w io.Writer, path string) error
- func New(w io.Writer, level slog.Leveler) *slog.Logger
- func NewID() string
- func Open(o Options) (*slog.Logger, io.Closer, error)
- func ParseLevel(s string) (slog.Level, error)
- type Options
Constants ¶
const ( KeyRun = "run" KeyVersion = "version" KeyDurationMS = "duration_ms" KeyGHRequestID = "gh_request_id" KeyRateRemaining = "rate_remaining" )
Attribute keys every package uses, so a log line can be searched by them.
const ( DefaultMaxSize = 10 << 20 DefaultKeep = 3 )
Rotation defaults: the file is moved aside when it is over MaxSize at startup, and Keep old files are kept.
Variables ¶
This section is empty.
Functions ¶
func DefaultPath ¶
func DefaultPath() string
DefaultPath is where the log file goes: log/gist.log in the state directory.
func Follow ¶
Follow writes each line added to the log file at path to w, until ctx is done. It follows the file through a rotation, and waits for a file that does not exist yet.