trace

package
v0.0.0-...-f6ab670 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 7 Imported by: 25

Documentation

Overview

Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at

http://aws.amazon.com/apache2.0/

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NanoTime

type NanoTime interface {
	NowUnixNano() int64
}

NanoTime is helper interface for mocking time

type PluginOutputTrace

type PluginOutputTrace struct {
	Tracer Tracer
	// contains filtered or unexported fields
}

func (*PluginOutputTrace) AppendDebug

func (po *PluginOutputTrace) AppendDebug(log log.T, message string)

func (*PluginOutputTrace) AppendDebugf

func (po *PluginOutputTrace) AppendDebugf(log log.T, format string, params ...interface{})

func (*PluginOutputTrace) AppendError

func (po *PluginOutputTrace) AppendError(log log.T, message string)

func (*PluginOutputTrace) AppendErrorf

func (po *PluginOutputTrace) AppendErrorf(log log.T, format string, params ...interface{})

func (*PluginOutputTrace) AppendInfo

func (po *PluginOutputTrace) AppendInfo(log log.T, message string)

func (*PluginOutputTrace) AppendInfof

func (po *PluginOutputTrace) AppendInfof(log log.T, format string, params ...interface{})

func (*PluginOutputTrace) GetExitCode

func (po *PluginOutputTrace) GetExitCode() int

func (*PluginOutputTrace) GetStatus

func (po *PluginOutputTrace) GetStatus() contracts.ResultStatus

func (*PluginOutputTrace) GetStderr

func (po *PluginOutputTrace) GetStderr() string

func (*PluginOutputTrace) GetStdout

func (po *PluginOutputTrace) GetStdout() string

func (*PluginOutputTrace) MarkAsCancelled

func (out *PluginOutputTrace) MarkAsCancelled()

func (*PluginOutputTrace) MarkAsFailed

func (po *PluginOutputTrace) MarkAsFailed(log log.T, err error)

func (*PluginOutputTrace) MarkAsInProgress

func (out *PluginOutputTrace) MarkAsInProgress()

func (*PluginOutputTrace) MarkAsShutdown

func (out *PluginOutputTrace) MarkAsShutdown()

func (*PluginOutputTrace) MarkAsSucceeded

func (out *PluginOutputTrace) MarkAsSucceeded()

func (*PluginOutputTrace) MarkAsSuccessWithReboot

func (out *PluginOutputTrace) MarkAsSuccessWithReboot()

func (*PluginOutputTrace) SetExitCode

func (po *PluginOutputTrace) SetExitCode(exitCode int)

func (*PluginOutputTrace) SetStatus

func (po *PluginOutputTrace) SetStatus(status contracts.ResultStatus)

func (*PluginOutputTrace) String

func (out *PluginOutputTrace) String() string

type TimeImpl

type TimeImpl struct {
}

func (*TimeImpl) NowUnixNano

func (t *TimeImpl) NowUnixNano() int64

type Trace

type Trace struct {
	Tracer Tracer `json:"-"`
	Logger log.T  `json:"-"`

	Operation string
	// results
	Exitcode int64
	Error    string `json:",omitempty"`
	// timing
	Start int64
	Stop  int64 `json:",omitempty"`
	// output
	InfoOut  bytes.Buffer `json:"-"`
	ErrorOut bytes.Buffer `json:"-"`
}

func (*Trace) AppendDebug

func (t *Trace) AppendDebug(message string) *Trace

AppendDebug adds debug info to the trace

func (*Trace) AppendDebugf

func (t *Trace) AppendDebugf(format string, params ...interface{}) *Trace

AppendDebugf adds debug info to the trace

func (*Trace) AppendError

func (t *Trace) AppendError(message string) *Trace

AppendError adds errors to PluginOutput StandardErr.

func (*Trace) AppendErrorf

func (t *Trace) AppendErrorf(format string, params ...interface{}) *Trace

AppendErrorf adds errors to PluginOutput StandardErr with formatting parameters.

func (*Trace) AppendInfo

func (t *Trace) AppendInfo(message string) *Trace

AppendInfo adds info to PluginOutput StandardOut.

func (*Trace) AppendInfof

func (t *Trace) AppendInfof(format string, params ...interface{}) *Trace

AppendInfof adds info to PluginOutput StandardOut with formatting parameters.

func (*Trace) AppendWithSubtraces

func (t *Trace) AppendWithSubtraces(message string) *Trace

func (*Trace) End

func (t *Trace) End() error

End will close the trace. Afterwards no other operation should be called.

func (*Trace) EndWithError

func (t *Trace) EndWithError(err *error) *Trace

EndWithError just combines two commonly used methods to be able to use it in combination with defer

func asdf(tracer Tracer) {
		var err error
		defer tracer.BeginSection("testtracemsg").EndWithError(err)
		...
	}

func (*Trace) WithError

func (t *Trace) WithError(err error) *Trace

WithError sets the error of the trace

func (*Trace) WithExitcode

func (t *Trace) WithExitcode(exitcode int64) *Trace

WithExitcode sets the exitcode of the trace

type Tracer

type Tracer interface {
	BeginSection(message string) *Trace
	EndSection(trace *Trace) error
	AddTrace(trace *Trace)

	Traces() []*Trace
	PrependTraces([]*Trace)
	CurrentTrace() *Trace

	ToPluginOutput() iohandler.IOHandler
}

Tracer is used for collecting traces during a package installation

func NewTracer

func NewTracer(logger log.T) Tracer

func NewTracerCustomTime

func NewTracerCustomTime(timeProvider NanoTime, logger log.T) Tracer

type TracerImpl

type TracerImpl struct {
	// contains filtered or unexported fields
}

TracerImpl implements the Tracer interface for collecting traces

func (*TracerImpl) AddTrace

func (t *TracerImpl) AddTrace(trace *Trace)

AddTrace takes a one time trace without tracking a duration

func (*TracerImpl) BeginSection

func (t *TracerImpl) BeginSection(message string) *Trace

BeginSection will create a new trace and registers with the tracer

func (*TracerImpl) CurrentTrace

func (t *TracerImpl) CurrentTrace() *Trace

CurrentTrace will return the last unclosed trace If no trace is open it will return nil

func (*TracerImpl) EndSection

func (t *TracerImpl) EndSection(trace *Trace) error

EndSection will close the trace provided in the parameter. If the provided trace is not the upper one on the stack it will close all traces in between.

func (*TracerImpl) PrependTraces

func (t *TracerImpl) PrependTraces(traces []*Trace)

PrependTraces takes existing traces and add them at the beginning while also setting their Tracer and Logger

func (*TracerImpl) ToPluginOutput

func (t *TracerImpl) ToPluginOutput() iohandler.IOHandler

ToPluginOutput will convert info and error output into a IOHandler struct It will sort the output by trace end time

func (*TracerImpl) Traces

func (t *TracerImpl) Traces() []*Trace

Traces will return all closed traces

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL