Documentation ¶
Overview ¶
Package logger provides functionality for logging command execution records.
Index ¶
- func AddCompletionStatus(rec *LogRecord, execStrategy ppb.ExecutionStrategy_Value)
- func CommandRemoteMetadataFromProto(rPb *lpb.RemoteMetadata) *command.Metadata
- func CommandRemoteMetadataToProto(r *command.Metadata) *lpb.RemoteMetadata
- func ParseFromFile(format Format, filepath string) ([]*lpb.LogRecord, error)
- func ParseFromFormatFile(formatfile string) ([]*lpb.LogRecord, error)
- func ParseFromLogDirs(format Format, logDirs []string) ([]*lpb.LogRecord, []*lpb.ProxyInfo, error)
- type Format
- type LogRecord
- type Logger
- func (l *Logger) AddEventTimeToProxyInfo(key string, from, to time.Time)
- func (l *Logger) AddEventTimesToProxyInfo(m map[string]*cpb.TimeInterval)
- func (l *Logger) AddFlagStringToProxyInfo(key string, value string)
- func (l *Logger) AddFlags(flagSet *flag.FlagSet)
- func (l *Logger) AddMetricBoolToProxyInfo(key string, value bool)
- func (l *Logger) AddMetricDoubleToProxyInfo(key string, value float64)
- func (l *Logger) AddMetricIntToProxyInfo(key string, value int64)
- func (l *Logger) CloseAndAggregate() *spb.Stats
- func (l *Logger) GetStatusSummary(ctx context.Context, _ *ppb.GetStatusSummaryRequest) (*ppb.GetStatusSummaryResponse, error)
- func (l *Logger) IncrementMetricIntToProxyInfo(key string, delta int64)
- func (l *Logger) Log(rec *LogRecord)
- func (l *Logger) LogActionStart() *LogRecord
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 ¶
ParseFromFile reads Records from a log file created by a Logger.
func ParseFromFormatFile ¶
ParseFromFormatFile reads Records from a log file created by a Logger. Deprecated: TODO(b/279058022): remove this when format file is no longer used.
Types ¶
type Format ¶
type Format int
Format specifies how the Logger serializes its records.
func ParseFilepath ¶
ParseFilepath parses the given formatfile path and returns the format and filename of the given log file.
func ParseFormat ¶
ParseFormat parses a string log file format into the enum.
type LogRecord ¶
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 ¶
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 ¶
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 stats.StatCollector, mi *ignoremismatch.MismatchIgnorer, e monitoring.StatExporter, u *usage.PsutilSampler, bqSpec *bigquery.BQSpec) (*Logger, error)
New instantiates a new Logger.
func NewFromFormatFile ¶
func NewFromFormatFile(formatfile string, s stats.StatCollector, mi *ignoremismatch.MismatchIgnorer, e monitoring.StatExporter, u *usage.PsutilSampler, bqSpec *bigquery.BQSpec) (*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 ¶
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 ¶
AddFlagStringToProxyInfo will add an reproxy flag to the ProxyInfo object.
func (*Logger) AddMetricBoolToProxyInfo ¶
AddMetricBoolToProxyInfo will add an reproxy level event to the ProxyInfo object.
func (*Logger) AddMetricDoubleToProxyInfo ¶
AddMetricDoubleToProxyInfo will add an reproxy level event to the ProxyInfo object.
func (*Logger) AddMetricIntToProxyInfo ¶
AddMetricIntToProxyInfo will add an reproxy level event to the ProxyInfo object.
func (*Logger) CloseAndAggregate ¶
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 ¶
func (l *Logger) GetStatusSummary(ctx context.Context, _ *ppb.GetStatusSummaryRequest) (*ppb.GetStatusSummaryResponse, error)
GetStatusSummary returns a snapshot for currently running and completed actions.
func (*Logger) IncrementMetricIntToProxyInfo ¶
IncrementMetricIntToProxyInfo will increment a reproxy level event to the ProxyInfo object.
func (*Logger) LogActionStart ¶
LogActionStart logs start of an action. Use the returned LogRecord to track log events then pass to Log at the end of the action.