reporter

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitWithReport

func ExitWithReport(v ...any)

ExitWithReport prints to the logger and exit with 0. Arguments are handled in the manner of fmt.Println.

func Fatal

func Fatal(v ...any)

Fatal prints to the logger and exit with 1. Arguments are handled in the manner of fmt.Println.

func InitReporter

func InitReporter()

Init the log.

func Report

func Report(v ...any)

Report prints to the logger. Arguments are handled in the manner of fmt.Println.

func ReportEventTo

func ReportEventTo(event *KpmEvent, w io.Writer)

ReportEvent reports the event to users to stdout.

func ReportEventToStderr

func ReportEventToStderr(event *KpmEvent)

ReportEventToStderr reports the event to users to stderr.

func ReportEventToStdout

func ReportEventToStdout(event *KpmEvent)

ReportEventToStdout reports the event to users to stdout.

Types

type Event

type Event interface {
	Event() string
}

Event is the interface that specifies the event used to show logs to users.

type EventType

type EventType int
const (
	Default EventType = iota

	// errors event type means the event is an error.
	InvalidRepo
	FailedNewOciClient
	RepoNotFound
	FailedLoadSettings
	FailedLoadCredential
	FailedCreateOciClient
	FailedSelectLatestVersion
	FailedGetPackageVersions
	FailedCreateStorePath
	FailedPush
	FailedGetPkg
	FailedAccessPkgPath
	UnKnownPullWhat
	UnknownEnv
	InvalidKclPkg
	FailedUntarKclPkg
	FailedLoadKclMod
	CheckSumMismatch
	CalSumFailed
	InvalidKpmHomeInCurrentPkg
	InvalidCmd
	InvalidPkgRef
	InvalidGitUrl
	WithoutGitTag
	FailedCloneFromGit
	FailedHashPkg
	Bug

	// normal event type means the event is a normal event.
	PullingStarted
	PullingFinished
	Pulling
	Adding
	IsNotUrl
	IsNotRef
	UrlSchemeNotOci
	UnsupportOciUrlScheme
	SelectLatestVersion
	DownloadingFromOCI
	DownloadingFromGit
	LocalPathNotExist
	PathIsEmpty
	AddItselfAsDep
	PkgTagExists
	DependencyNotFound
	CompileFailed
)

type KpmEvent

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

KpmEvent is the event used to show kpm logs to users.

func NewErrorEvent

func NewErrorEvent(errType EventType, err error, args ...string) *KpmEvent

NewErrorEvent returns a new KpmEvent with error.

func NewEvent

func NewEvent(errType EventType, args ...string) *KpmEvent

NewEvent returns a new KpmEvent without error.

func (*KpmEvent) Error

func (e *KpmEvent) Error() string

Error makes KpmEvent can be used as an error.

func (*KpmEvent) Event

func (e *KpmEvent) Event() string

Event returns the msg of the event without error message.

func (*KpmEvent) Type

func (e *KpmEvent) Type() EventType

Type returns the event type.

Jump to

Keyboard shortcuts

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