json_handler.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  	"io"
  11  	"log/slog"
  12  )
  13  
  14  // JSONHandler is a Handler that writes Records to an io.Writer as
  15  // line-delimited JSON objects.
  16  type JSONHandler = slog.JSONHandler
  17  
  18  // NewJSONHandler creates a JSONHandler that writes to w,
  19  // using the given options.
  20  // If opts is nil, the default options are used.
  21  func NewJSONHandler(w io.Writer, opts *HandlerOptions) *JSONHandler {
  22  	return slog.NewJSONHandler(w, opts)
  23  }
  24