log

package
v0.0.0-...-31a059a Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	JSONLogger    = LoggerType(corelog.JSONLogger)
	ConsoleLogger = LoggerType(corelog.ConsoleLogger)
)
View Source
const (
	BitriseCLI = Producer(corelog.BitriseCLI)
	Step       = Producer(corelog.Step)
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug ...

func Debugf

func Debugf(format string, args ...interface{})

Debugf ...

func Done

func Done(args ...interface{})

Done ...

func Donef

func Donef(format string, args ...interface{})

Donef ...

func Error

func Error(args ...interface{})

Error ...

func Errorf

func Errorf(format string, args ...interface{})

Errorf ...

func Info

func Info(args ...interface{})

Info ...

func Infof

func Infof(format string, args ...interface{})

Infof ...

func InitGlobalLogger

func InitGlobalLogger(opts LoggerOpts)

InitGlobalLogger ...

func LogMessage

func LogMessage(message string, level corelog.Level)

LogMessage ...

func Print

func Print(args ...interface{})

Print ...

func PrintBitriseStartedEvent

func PrintBitriseStartedEvent(plan models.WorkflowRunPlan)

func PrintStepFinishedEvent

func PrintStepFinishedEvent(params StepFinishedParams)

func PrintStepStartedEvent

func PrintStepStartedEvent(params StepStartedParams)

func Printf

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

Printf ...

func Warn

func Warn(args ...interface{})

Warn ...

func Warnf

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

Warnf ...

Types

type ConsoleLoggerOpts

type ConsoleLoggerOpts struct {
	Timestamp bool
}

type Logger

type Logger interface {
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Done(args ...interface{})
	Donef(format string, args ...interface{})
	Print(args ...interface{})
	Printf(format string, args ...interface{})
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	LogMessage(message string, level corelog.Level)
	PrintBitriseStartedEvent(plan models.WorkflowRunPlan)
	PrintStepStartedEvent(params StepStartedParams)
	PrintStepFinishedEvent(params StepFinishedParams)
}

Logger ...

Example
package main

import (
	"os"
	"time"

	"github.com/bitrise-io/bitrise/log"
)

func referenceTime() time.Time {
	return time.Date(2022, 1, 1, 1, 1, 1, 0, time.UTC)
}

func main() {
	var logger log.Logger

	logger = log.NewLogger(log.LoggerOpts{
		LoggerType:      log.ConsoleLogger,
		Producer:        log.BitriseCLI,
		DebugLogEnabled: true,
		Writer:          os.Stdout,
		TimeProvider:    referenceTime,
	})
	logger.Errorf("This is an %s", "error")

	logger = log.NewLogger(log.LoggerOpts{
		LoggerType:      log.JSONLogger,
		Producer:        log.BitriseCLI,
		DebugLogEnabled: true,
		Writer:          os.Stdout,
		TimeProvider:    referenceTime,
	})
	logger.Debug("This is a debug message")

	log.InitGlobalLogger(log.LoggerOpts{
		LoggerType:      log.JSONLogger,
		Producer:        log.BitriseCLI,
		DebugLogEnabled: true,
		Writer:          os.Stdout,
		TimeProvider:    referenceTime,
	})
	log.Info("This is an info message")
}
Output:

func NewLogger

func NewLogger(opts LoggerOpts) Logger

NewLogger ...

type LoggerOpts

type LoggerOpts struct {
	LoggerType        LoggerType
	Producer          Producer
	ProducerID        string
	ConsoleLoggerOpts ConsoleLoggerOpts
	DebugLogEnabled   bool
	Writer            io.Writer
	TimeProvider      func() time.Time
}

func GetGlobalLoggerOpts

func GetGlobalLoggerOpts() LoggerOpts

GetGlobalLoggerOpts ...

type LoggerType

type LoggerType corelog.LoggerType

type MessageFields

type MessageFields corelog.MessageLogFields

type Producer

type Producer corelog.Producer

type StepDeprecation

type StepDeprecation struct {
	RemovalDate string `json:"removal_date"`
	Note        string `json:"note"`
}

StepDeprecation ...

type StepFinishedParams

type StepFinishedParams struct {
	ExecutionID   string             `json:"uuid"`
	Status        string             `json:"status"`
	StatusReason  string             `json:"status_reason,omitempty"`
	Title         string             `json:"title"`
	RunTime       int64              `json:"run_time_in_ms"`
	SupportURL    string             `json:"support_url"`
	SourceCodeURL string             `json:"source_code_url"`
	Errors        []models.StepError `json:"errors,omitempty"`
	// The update and deprecation fields are pointers because an empty struct is always initialised so never omitted.
	Update      *StepUpdate      `json:"update_available,omitempty"`
	Deprecation *StepDeprecation `json:"deprecation,omitempty"`
	LastStep    bool             `json:"last_step"`
}

StepFinishedParams ...

type StepStartedParams

type StepStartedParams struct {
	ExecutionID string `json:"uuid"`
	Position    int    `json:"idx"`
	Title       string `json:"title"`
	ID          string `json:"id"`
	Version     string `json:"version"`
	Collection  string `json:"collection"`
	Toolkit     string `json:"toolkit"`
	StartTime   string `json:"start_time"`
}

StepStartedParams ...

type StepUpdate

type StepUpdate struct {
	OriginalVersion string `json:"original_version"`
	ResolvedVersion string `json:"resolved_version"`
	LatestVersion   string `json:"latest_version"`
	ReleasesURL     string `json:"release_notes"`
}

StepUpdate ...

type UtilsLogAdapter

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

UtilsLogAdapter extends the bitrise/log.Logger to meet the go-utils/v2/log.Logger interface.

func NewUtilsLogAdapter

func NewUtilsLogAdapter() UtilsLogAdapter

func (*UtilsLogAdapter) EnableDebugLog

func (l *UtilsLogAdapter) EnableDebugLog(enable bool)

func (*UtilsLogAdapter) Println

func (l *UtilsLogAdapter) Println()

func (*UtilsLogAdapter) TDebugf

func (l *UtilsLogAdapter) TDebugf(format string, v ...interface{})

func (*UtilsLogAdapter) TDonef

func (l *UtilsLogAdapter) TDonef(format string, v ...interface{})

func (*UtilsLogAdapter) TErrorf

func (l *UtilsLogAdapter) TErrorf(format string, v ...interface{})

func (*UtilsLogAdapter) TInfof

func (l *UtilsLogAdapter) TInfof(format string, v ...interface{})

func (*UtilsLogAdapter) TPrintf

func (l *UtilsLogAdapter) TPrintf(format string, v ...interface{})

func (*UtilsLogAdapter) TWarnf

func (l *UtilsLogAdapter) TWarnf(format string, v ...interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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