...

Source file src/github.com/Microsoft/go-winio/pkg/etw/eventopt.go

Documentation: github.com/Microsoft/go-winio/pkg/etw

     1  //go:build windows
     2  // +build windows
     3  
     4  package etw
     5  
     6  import (
     7  	"github.com/Microsoft/go-winio/pkg/guid"
     8  )
     9  
    10  type eventOptions struct {
    11  	descriptor        *eventDescriptor
    12  	activityID        guid.GUID
    13  	relatedActivityID guid.GUID
    14  	tags              uint32
    15  }
    16  
    17  // EventOpt defines the option function type that can be passed to
    18  // Provider.WriteEvent to specify general event options, such as level and
    19  // keyword.
    20  type EventOpt func(options *eventOptions)
    21  
    22  // WithEventOpts returns the variadic arguments as a single slice.
    23  func WithEventOpts(opts ...EventOpt) []EventOpt {
    24  	return opts
    25  }
    26  
    27  // WithLevel specifies the level of the event to be written.
    28  func WithLevel(level Level) EventOpt {
    29  	return func(options *eventOptions) {
    30  		options.descriptor.level = level
    31  	}
    32  }
    33  
    34  // WithKeyword specifies the keywords of the event to be written. Multiple uses
    35  // of this option are OR'd together.
    36  func WithKeyword(keyword uint64) EventOpt {
    37  	return func(options *eventOptions) {
    38  		options.descriptor.keyword |= keyword
    39  	}
    40  }
    41  
    42  // WithChannel specifies the channel of the event to be written.
    43  func WithChannel(channel Channel) EventOpt {
    44  	return func(options *eventOptions) {
    45  		options.descriptor.channel = channel
    46  	}
    47  }
    48  
    49  // WithOpcode specifies the opcode of the event to be written.
    50  func WithOpcode(opcode Opcode) EventOpt {
    51  	return func(options *eventOptions) {
    52  		options.descriptor.opcode = opcode
    53  	}
    54  }
    55  
    56  // WithTags specifies the tags of the event to be written. Tags is a 28-bit
    57  // value (top 4 bits are ignored) which are interpreted by the event consumer.
    58  func WithTags(newTags uint32) EventOpt {
    59  	return func(options *eventOptions) {
    60  		options.tags |= newTags
    61  	}
    62  }
    63  
    64  // WithActivityID specifies the activity ID of the event to be written.
    65  func WithActivityID(activityID guid.GUID) EventOpt {
    66  	return func(options *eventOptions) {
    67  		options.activityID = activityID
    68  	}
    69  }
    70  
    71  // WithRelatedActivityID specifies the parent activity ID of the event to be written.
    72  func WithRelatedActivityID(activityID guid.GUID) EventOpt {
    73  	return func(options *eventOptions) {
    74  		options.relatedActivityID = activityID
    75  	}
    76  }
    77  

View as plain text