1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build go1.21 6 7 package slog 8 9 import ( 10 "log/slog" 11 ) 12 13 // A Handler handles log records produced by a Logger.. 14 // 15 // A typical handler may print log records to standard error, 16 // or write them to a file or database, or perhaps augment them 17 // with additional attributes and pass them on to another handler. 18 // 19 // Any of the Handler's methods may be called concurrently with itself 20 // or with other methods. It is the responsibility of the Handler to 21 // manage this concurrency. 22 // 23 // Users of the slog package should not invoke Handler methods directly. 24 // They should use the methods of [Logger] instead. 25 type Handler = slog.Handler 26 27 // HandlerOptions are options for a TextHandler or JSONHandler. 28 // A zero HandlerOptions consists entirely of default values. 29 type HandlerOptions = slog.HandlerOptions 30 31 // Keys for "built-in" attributes. 32 const ( 33 // TimeKey is the key used by the built-in handlers for the time 34 // when the log method is called. The associated Value is a [time.Time]. 35 TimeKey = slog.TimeKey 36 // LevelKey is the key used by the built-in handlers for the level 37 // of the log call. The associated value is a [Level]. 38 LevelKey = slog.LevelKey 39 // MessageKey is the key used by the built-in handlers for the 40 // message of the log call. The associated value is a string. 41 MessageKey = slog.MessageKey 42 // SourceKey is the key used by the built-in handlers for the source file 43 // and line of the log call. The associated value is a string. 44 SourceKey = slog.SourceKey 45 ) 46