golang.org/x/build@v0.0.0-20240506185731-218518f32b70/internal/spanlog/spanlog.go (about)

     1  // Copyright 2020 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  // Package spanlog provides span and event logger interfaces.
     6  package spanlog
     7  
     8  // SpanLogger is something that has the CreateSpan method, which
     9  // creates a event spanning some duration which will eventually be
    10  // logged and visualized.
    11  type Logger interface {
    12  	// CreateSpan logs the start of an event.
    13  	// optText is 0 or 1 strings.
    14  	CreateSpan(event string, optText ...string) Span
    15  }
    16  
    17  // Span is a handle that can eventually be closed.
    18  // Typical usage:
    19  //
    20  //	sp := sl.CreateSpan("slow_operation")
    21  //	result, err := doSlowOperation()
    22  //	sp.Done(err)
    23  //	// do something with result, err
    24  type Span interface {
    25  	// Done marks a span as done.
    26  	// The err is returned unmodified for convenience at callsites.
    27  	Done(err error) error
    28  }