conslogging

package
v0.8.17-test1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2025 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NoPadding means the old behavior of printing the full target only.
	NoPadding int = -1
	// DefaultPadding always prints 20 characters for the target, right
	// justified. If it is longer, it prints the right 20 characters.
	DefaultPadding int = 20
)
View Source
const (
	// StatusWaiting is the status for a target that has yet to execute.
	StatusWaiting = "waiting"

	// StatusInProgress is the status for a target that is currently executing.
	StatusInProgress = "in_progress"

	// StatusComplete is the status for a target that has run to completion.
	StatusComplete = "complete"

	// StatusCancelled is the status for a target that did not run to completion, and was interrupted.
	StatusCancelled = "cancelled"

	// ResultSuccess is the result for a target that exits successfully.
	ResultSuccess = "success"

	// ResultFailure is the result for a target that exited with some kind of error code.
	ResultFailure = "failure"

	// ResultCancelled is the results for a target that did not run to completion.
	ResultCancelled = "cancelled"
)

These types are also used by our log server, too.

Variables

This section is empty.

Functions

func NewPrefixFormatter

func NewPrefixFormatter(formatOpt ...formatOpt) *prefixFormatter

Types

type BufferedLogger

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

BufferedLogger is a logger that queues up messages until Flush is called.

func NewBufferedLogger

func NewBufferedLogger(cl *ConsoleLogger) *BufferedLogger

NewBufferedLogger creates a new BufferedLogger.

func (*BufferedLogger) Flush

func (bl *BufferedLogger) Flush()

Flush prints the queued up messages to the underlying console.

func (*BufferedLogger) Printf

func (bl *BufferedLogger) Printf(format string, v ...interface{})

Printf prints a formatted string to the delayed console.

type ColorMode

type ColorMode int

ColorMode is the mode in which colors are represented in the output.

const (
	// AutoColor automatically detects the presence of a TTY to decide if
	// color should be used.
	AutoColor ColorMode = iota
	// NoColor disables use of color.
	NoColor
	// ForceColor forces use of color.
	ForceColor
)

type ConsoleLogger

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

ConsoleLogger is a writer for consoles.

func Current

func Current(colorMode ColorMode, prefixPadding int, logLevel LogLevel, githubAnnotations bool) ConsoleLogger

Current returns the current console.

func New

func New(w io.Writer, mu *sync.Mutex, colorMode ColorMode, prefixPadding int, logLevel LogLevel, githubAnnotations bool) ConsoleLogger

New returns a new ConsoleLogger with a predefined target writer.

func (ConsoleLogger) ColorPrintf

func (cl ConsoleLogger) ColorPrintf(c *color.Color, format string, args ...interface{})

func (ConsoleLogger) DebugBytes

func (cl ConsoleLogger) DebugBytes(data []byte)

DebugBytes prints bytes directly to the console when debug flag is set.

func (ConsoleLogger) DebugPrintf

func (cl ConsoleLogger) DebugPrintf(format string, args ...interface{})

DebugPrintf prints formatted text to the console when debug flag is set.

func (ConsoleLogger) HelpPrintf

func (cl ConsoleLogger) HelpPrintf(format string, args ...interface{})

HelpPrintf prints formatted text to the console with `Help:` prefix in a specific color

func (ConsoleLogger) Prefix

func (cl ConsoleLogger) Prefix() string

Prefix returns the console's prefix.

func (ConsoleLogger) PrefixColor

func (cl ConsoleLogger) PrefixColor() *color.Color

PrefixColor returns the color used for the prefix.

func (ConsoleLogger) PrintBar

func (cl ConsoleLogger) PrintBar(c *color.Color, msg, phase string)

PrintBar prints an earthly message bar.

func (ConsoleLogger) PrintBytes

func (cl ConsoleLogger) PrintBytes(data []byte)

PrintBytes prints bytes directly to the console.

func (ConsoleLogger) PrintFailure

func (cl ConsoleLogger) PrintFailure(phase string)

PrintFailure prints the failure message.

func (*ConsoleLogger) PrintGHAError

func (cl *ConsoleLogger) PrintGHAError(message string, fns ...GHAErrorOpt)

PrintGHAError constructs a GitHub Actions error message.

func (*ConsoleLogger) PrintGHASummary

func (cl *ConsoleLogger) PrintGHASummary(message string)

Prints a GitHub Actions summary message to GITHUB_STEP_SUMMARY

func (ConsoleLogger) PrintPhaseFooter

func (cl ConsoleLogger) PrintPhaseFooter(phase string, disabled bool, special string)

PrintPhaseFooter prints the phase footer.

func (ConsoleLogger) PrintPhaseHeader

func (cl ConsoleLogger) PrintPhaseHeader(phase string, disabled bool, special string)

PrintPhaseHeader prints the phase header.

func (ConsoleLogger) PrintSuccess

func (cl ConsoleLogger) PrintSuccess()

PrintSuccess prints the success message.

func (ConsoleLogger) Printf

func (cl ConsoleLogger) Printf(format string, args ...interface{})

Printf prints formatted text to the console.

func (ConsoleLogger) Salt

func (cl ConsoleLogger) Salt() string

Salt returns the console's salt.

func (ConsoleLogger) VerboseBytes

func (cl ConsoleLogger) VerboseBytes(data []byte)

VerboseBytes prints bytes directly to the console when verbose flag is set.

func (ConsoleLogger) VerbosePrintf

func (cl ConsoleLogger) VerbosePrintf(format string, args ...interface{})

VerbosePrintf prints formatted text to the console when verbose flag is set.

func (ConsoleLogger) VerboseWarnf

func (cl ConsoleLogger) VerboseWarnf(format string, args ...interface{})

VerboseWarnf prints a warning message in red to errWriter when verbose flag is set.

func (ConsoleLogger) Warnf

func (cl ConsoleLogger) Warnf(format string, args ...interface{})

Warnf prints a warning message in red to errWriter.

func (ConsoleLogger) WithCached

func (cl ConsoleLogger) WithCached(isCached bool) ConsoleLogger

WithCached returns a ConsoleLogger with isCached flag set accordingly.

func (ConsoleLogger) WithFailed

func (cl ConsoleLogger) WithFailed(isFailed bool) ConsoleLogger

WithFailed returns a ConsoleLogger with isFailed flag set accordingly.

func (ConsoleLogger) WithLocal

func (cl ConsoleLogger) WithLocal(isLocal bool) ConsoleLogger

WithLocal returns a ConsoleLogger with local set.

func (ConsoleLogger) WithLogLevel

func (cl ConsoleLogger) WithLogLevel(logLevel LogLevel) ConsoleLogger

WithLogLevel changes the log level

func (ConsoleLogger) WithMetadataMode

func (cl ConsoleLogger) WithMetadataMode(metadataMode bool) ConsoleLogger

WithMetadataMode returns a ConsoleLogger with metadata printing mode set.

func (ConsoleLogger) WithPrefix

func (cl ConsoleLogger) WithPrefix(prefix string) ConsoleLogger

WithPrefix returns a ConsoleLogger with a prefix added.

func (ConsoleLogger) WithPrefixAndSalt

func (cl ConsoleLogger) WithPrefixAndSalt(prefix string, salt string) ConsoleLogger

WithPrefixAndSalt returns a ConsoleLogger with a prefix and a seed added.

func (ConsoleLogger) WithPrefixWriter

func (cl ConsoleLogger) WithPrefixWriter(w PrefixWriter) ConsoleLogger

WithPrefixWriter returns a ConsoleLogger with a prefix writer.

func (ConsoleLogger) WithWriter

func (cl ConsoleLogger) WithWriter(w io.Writer) ConsoleLogger

WithWriter returns a ConsoleLogger with stderr pointed at the provided io.Writer.

type GHAError

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

func (*GHAError) FormattedMessage

func (e *GHAError) FormattedMessage() string

type GHAErrorOpt

type GHAErrorOpt func(*GHAError)

func WithGHASourceLocation

func WithGHASourceLocation(file string, line, col int32) GHAErrorOpt

type LogLevel

type LogLevel int

LogLevel defines which types of log messages are displayed (e.g. warning, info, verbose)

const (
	// Silent silences logging
	Silent LogLevel = iota
	// Warn only display warning log messages
	Warn
	// Info displays info and higher priority log messages
	Info
	// Verbose displays verbose and higher priority log messages
	Verbose
	// Debug displays all log messages
	Debug
)

type Manifest

type Manifest struct {
	Version    int              `json:"version"`
	Duration   int              `json:"duration"`
	Status     string           `json:"status"`
	Result     string           `json:"result"`
	CreatedAt  time.Time        `json:"created_at"`
	Targets    []TargetManifest `json:"targets"`
	Entrypoint string           `json:"entrypoint"`
}

Manifest is the structure for the log bundle manifest, including all overarching data we need.

type Permissions

type Permissions struct {
	Version int      `json:"version"`
	Users   []string `json:"users"`
	Orgs    []string `json:"orgs"`
}

Permissions is the structure for the permissions manifest that can grant view rights to other Earthly users.

type PrefixWriter

type PrefixWriter interface {
	io.Writer
	// WithPrefix returns a new PrefixWriter with the given prefix.
	WithPrefix(prefix string) PrefixWriter
}

PrefixWriter is a writer that can take a prefix.

type TargetManifest

type TargetManifest struct {
	Name     string `json:"name"`
	Status   string `json:"status"`
	Result   string `json:"result"`
	Duration int    `json:"duration"`
	Size     int    `json:"size"`
	Command  string `json:"command,omitempty"`
	Summary  string `json:"summary,omitempty"`
}

TargetManifest is the structure for an individual target, indicating all relevant information.

Jump to

Keyboard shortcuts

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