cilog

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Can

func Can(l Logger, capability Capability) bool

Can tells if the logger has specified logging capability.

func Debug added in v0.3.0

func Debug(l Logger, s string)

Debug - emitting debug log. If the given logger doesn't support CapabilityDebugLog, fallbacks to Log.

func Error added in v0.3.0

func Error(l Logger, s string)

Error - emitting error log. If the given logger doesn't support CapabilityErrorLog, fallbacks to Log.

func Notice added in v0.3.0

func Notice(l Logger, s string)

Notice - emitting notice log. If the given logger doesn't support CapabilityNoticeLog, fallbacks to Log.

func Warning added in v0.3.0

func Warning(l Logger, s string)

Warning - emitting warning log. If the given logger doesn't support CapabilityWarningLog, fallbacks to Log.

Types

type AzurePipelineOpts

type AzurePipelineOpts = applyOpts[azurePipelineT]

AzurePipelineOpts configures AzurePipeline logger.

func AzurePipelineUseLogIssue added in v0.2.0

func AzurePipelineUseLogIssue(yes bool) AzurePipelineOpts

AzurePipelineUseLogIssue controls AzurePipeline logger to log with LogIssue command.

ref: https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands?view=azure-devops&tabs=bash#logissue-log-an-error-or-warning

type Capability

type Capability int
const (
	// CapabilityLog - prints a basic log
	CapabilityLog Capability = iota
	// CapabilityColor - prints log with color
	CapabilityColor
	// CapabilityDebugLog - emitting debug log
	CapabilityDebugLog
	// CapabilityNoticeLog - emitting notice log
	CapabilityNoticeLog
	// CapabilityWarningLog - emitting warning log
	CapabilityWarningLog
	// CapabilityErrorLog - emitting error log
	CapabilityErrorLog
	// CapabilityGroupLog - emitting logs as a group
	CapabilityGroupLog
)

type GitHubOpts

type GitHubOpts = applyOpts[githubActionsT]

GitHubOpts configures GitHubActions logger.

type GroupLogParams

type GroupLogParams struct {
	// Name - name of the group
	Name string
}

GroupLogParams specifies the parameter for GroupLog.

type Logger

type Logger interface {
	// SetOutput sets the output of the logger.
	// This is useful unit testing usage.
	SetOutput(io.Writer)

	// Capabilities returns the capabilities of the logger.
	Capabilities() map[Capability]struct{}

	// Log - prints a basic log (CapabilityLog)
	Log(s string)

	// DebugLog - emitting debug log (CapabilityDebugLog)
	DebugLog(s string)

	// NoticeLog - emitting notice log (CapabilityNoticeLog)
	NoticeLog(s string)

	// WarningLog - emitting warning log (CapabilityWarningLog)
	WarningLog(s string)

	// ErrorLog - emitting error log (CapabilityErrorLog)
	ErrorLog(s string)

	// GroupLog - emitting logs as a group (CapabilityGroupLog)
	GroupLog(params GroupLogParams) (groupLogger Logger, endGroup func())
}

Logger provides improved CI logging output.

func AzurePipeline

func AzurePipeline(opts ...AzurePipelineOpts) Logger

AzurePipeline creates an AzurePipeline logger.

refs: - https://learn.microsoft.com/en-us/azure/devops/pipelines/scripts/logging-commands

func Get

func Get(name ci.Name) Logger

Get returns a logger based on CI environment. If no supported logger defined, a generic logger will be returned.

func GitHubActions

func GitHubActions(opts ...GitHubOpts) Logger

GitHubActions creates a GitHubActions logger.

refs: - https://github.com/actions/toolkit/blob/master/docs/commands.md

func Group added in v0.2.0

func Group(l Logger, params GroupLogParams) (Logger, func())

Group starts a group logger. If the given logger doesn't support group logging, the original logger will be returned and a noop finish function will be returned.

type Mute

type Mute struct {
}

Mute implements all Logger methods by muting output.

func (*Mute) Capabilities

func (m *Mute) Capabilities() map[Capability]struct{}

func (*Mute) DebugLog

func (m *Mute) DebugLog(s string)

func (*Mute) ErrorLog

func (m *Mute) ErrorLog(s string)

func (*Mute) GroupLog

func (m *Mute) GroupLog(GroupLogParams) (Logger, func())

func (*Mute) Log

func (m *Mute) Log(s string)

func (*Mute) NoticeLog

func (m *Mute) NoticeLog(s string)

func (*Mute) SetOutput added in v0.2.0

func (m *Mute) SetOutput(o io.Writer)

func (*Mute) WarningLog

func (m *Mute) WarningLog(s string)

Jump to

Keyboard shortcuts

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