record.go raw

   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  	"time"
  12  )
  13  
  14  // A Record holds information about a log event.
  15  // Copies of a Record share state.
  16  // Do not modify a Record after handing out a copy to it.
  17  // Call [NewRecord] to create a new Record.
  18  // Use [Record.Clone] to create a copy with no shared state.
  19  type Record = slog.Record
  20  
  21  // NewRecord creates a Record from the given arguments.
  22  // Use [Record.AddAttrs] to add attributes to the Record.
  23  //
  24  // NewRecord is intended for logging APIs that want to support a [Handler] as
  25  // a backend.
  26  func NewRecord(t time.Time, level Level, msg string, pc uintptr) Record {
  27  	return slog.NewRecord(t, level, msg, pc)
  28  }
  29  
  30  // Source describes the location of a line of source code.
  31  type Source = slog.Source
  32