logger

package
v0.0.0-...-bf8e85a Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package logger provides functionality for logging command execution records.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCompletionStatus

func AddCompletionStatus(rec *LogRecord, execStrategy ppb.ExecutionStrategy_Value)

AddCompletionStatus adds the correct CommandResultStatus that summarizes the given LogRecord and ExecutionStrategy.

func CommandRemoteMetadataFromProto

func CommandRemoteMetadataFromProto(rPb *lpb.RemoteMetadata) *command.Metadata

CommandRemoteMetadataFromProto parses a RemoteMetadata proto into an sdk Metadata.

func CommandRemoteMetadataToProto

func CommandRemoteMetadataToProto(r *command.Metadata) *lpb.RemoteMetadata

CommandRemoteMetadataToProto converts the sdk Metadata to RemoteMetadata proto.

func ParseFromFile

func ParseFromFile(format Format, filepath string) ([]*lpb.LogRecord, error)

ParseFromFile reads Records from a log file created by a Logger.

func ParseFromFormatFile

func ParseFromFormatFile(formatfile string) ([]*lpb.LogRecord, error)

ParseFromFormatFile reads Records from a log file created by a Logger. Deprecated: TODO(b/279058022): remove this when format file is no longer used.

func ParseFromLogDirs

func ParseFromLogDirs(format Format, logDirs []string) ([]*lpb.LogRecord, []*lpb.ProxyInfo, error)

ParseFromLogDirs reads Records from log files created by a Logger.

Types

type ExportActionMetricsFunc

type ExportActionMetricsFunc func(ctx context.Context, lr *lpb.LogRecord, remoteDisabled bool)

ExportActionMetricsFunc is the type of "github.com/bazelbuild/reclient/internal/pkg/monitoring".Exporter.ExportActionMetrics

type Format

type Format int

Format specifies how the Logger serializes its records.

const (
	// TextFormat means records marshalled as proto-ASCII.
	TextFormat Format = iota

	// JSONFormat means records marshalled as JSON.
	JSONFormat

	// BinaryFormat means records marshalled as binary delimited by record size.
	BinaryFormat

	// ReducedTextFormat means records are marshalled as proto-ASCII without the
	// command inputs and args.
	ReducedTextFormat
)

func ParseFilepath

func ParseFilepath(formatfile string) (Format, string, error)

ParseFilepath parses the given formatfile path and returns the format and filename of the given log file.

func ParseFormat

func ParseFormat(fs string) (Format, error)

ParseFormat parses a string log file format into the enum.

func (Format) String

func (f Format) String() string

type LogRecord

type LogRecord struct {
	*lpb.LogRecord
	// contains filtered or unexported fields
}

LogRecord wraps proxy.LogRecord while tracking if the command has been ended yet for logging purposes.

func NewLogRecord

func NewLogRecord() *LogRecord

NewLogRecord creates a new LogRecord without logging the start of an action. Use Logger.LogActionStart to log the start of an action.

func (*LogRecord) CopyEventTimesFrom

func (lr *LogRecord) CopyEventTimesFrom(other *LogRecord)

CopyEventTimesFrom copies all entries from other.LocalMetadata.EventTimes to this LogRecord's LocalMetadata.EventTimes. This method is thread safe.

func (*LogRecord) EndAllEventTimes

func (lr *LogRecord) EndAllEventTimes()

EndAllEventTimes adds time.Now() as the end time for all entries in LocalMetadata.EventTimes. This method is thread safe.

func (*LogRecord) RecordEventTime

func (lr *LogRecord) RecordEventTime(event string, from time.Time) time.Time

RecordEventTime ensures LocalMetedata.EventTimes is instantiated, calculates the time interval between now and from, adds it to EventTimes with the given event String as key and returns the now time. This method is thread safe.

type Logger

type Logger struct {
	Format Format
	// contains filtered or unexported fields
}

Logger logs Records asynchronously into a file.

func New

func New(format Format, dir string, s statCollector, mi *ignoremismatch.MismatchIgnorer, e ExportActionMetricsFunc, u *usage.PsutilSampler) (*Logger, error)

New instantiates a new Logger.

func NewFromFormatFile

func NewFromFormatFile(formatfile string, s statCollector, mi *ignoremismatch.MismatchIgnorer, e ExportActionMetricsFunc, u *usage.PsutilSampler) (*Logger, error)

NewFromFormatFile instantiates a new Logger. TODO(b/279057640): this is deprecated, remove and use New instead when --log_path flag is gone.

func (*Logger) AddEventTimeToProxyInfo

func (l *Logger) AddEventTimeToProxyInfo(key string, from, to time.Time)

AddEventTimeToProxyInfo will add an reproxy level event to the ProxyInfo object.

func (*Logger) AddEventTimesToProxyInfo

func (l *Logger) AddEventTimesToProxyInfo(m map[string]*cpb.TimeInterval)

AddEventTimesToProxyInfo will add a map of reproxy level events to the ProxyInfo object.

func (*Logger) AddFlagStringToProxyInfo

func (l *Logger) AddFlagStringToProxyInfo(key string, value string)

AddFlagStringToProxyInfo will add an reproxy flag to the ProxyInfo object.

func (*Logger) AddFlags

func (l *Logger) AddFlags(flagSet *flag.FlagSet)

AddFlags will add all reproxy flags to the ProxyInfo object.

func (*Logger) AddMetricBoolToProxyInfo

func (l *Logger) AddMetricBoolToProxyInfo(key string, value bool)

AddMetricBoolToProxyInfo will add an reproxy level event to the ProxyInfo object.

func (*Logger) AddMetricDoubleToProxyInfo

func (l *Logger) AddMetricDoubleToProxyInfo(key string, value float64)

AddMetricDoubleToProxyInfo will add an reproxy level event to the ProxyInfo object.

func (*Logger) AddMetricIntToProxyInfo

func (l *Logger) AddMetricIntToProxyInfo(key string, value int64)

AddMetricIntToProxyInfo will add an reproxy level event to the ProxyInfo object.

func (*Logger) CloseAndAggregate

func (l *Logger) CloseAndAggregate() *spb.Stats

CloseAndAggregate deactivates the logger and waits for pending records to finish logging. The log file is then closed. Any subsequent Log calls will be discarded. Finally, aggregated build stats are generated and returned.

func (*Logger) GetStatusSummary

GetStatusSummary returns a snapshot for currently running and completed actions.

func (*Logger) IncrementMetricIntToProxyInfo

func (l *Logger) IncrementMetricIntToProxyInfo(key string, delta int64)

IncrementMetricIntToProxyInfo will increment a reproxy level event to the ProxyInfo object.

func (*Logger) Log

func (l *Logger) Log(rec *LogRecord)

Log will add the record to be logged asynchronously.

func (*Logger) LogActionStart

func (l *Logger) LogActionStart() *LogRecord

LogActionStart logs start of an action. Use the returned LogRecord to track log events then pass to Log at the end of the action.

Directories

Path Synopsis
Package event provides constant names for time metrics.
Package event provides constant names for time metrics.

Jump to

Keyboard shortcuts

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