color

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SupportAssumptionDetections = []SupportAssumptionDetection{
		SupportAssumptionDetectionIntellij,
		SupportAssumptionDetectionGitlabCi,
	}

	SupportAssumptionDetectionIntellij = func() bool {

		return os.Getenv("IDEA_INITIAL_DIRECTORY") != "" ||
			strings.Contains(os.Getenv("TERMINAL_EMULATOR"), "JetBrains")
	}

	SupportAssumptionDetectionGitlabCi = func() bool {

		return os.Getenv("CI_JOB_ID") != "" && os.Getenv("CI_RUNNER_ID") != ""
	}
)
View Source
var (
	ErrIllegalMode = errors.New("illegal color-mode")
)
View Source
var (
	ErrIllegalSupport = errors.New("illegal color-support")
)

Functions

This section is empty.

Types

type LevelBasedColorizer

type LevelBasedColorizer interface {
	Colorize(log.Level, string) string
}
var DefaultLevelBasedColorizer LevelBasedColorizer = LevelColorizerMap{
	log.LevelTrace: `�[30;1m`,
	log.LevelDebug: `�[36;1m`,
	log.LevelInfo:  `�[34;1m`,
	log.LevelWarn:  `�[33;1m`,
	log.LevelError: `�[31;1m`,
	log.LevelFatal: `�[35;1m`,
}

type LevelColorizerMap

type LevelColorizerMap map[log.Level]string

func (LevelColorizerMap) Colorize

func (l LevelColorizerMap) Colorize(level log.Level, what string) string

type Mode

type Mode uint8
const (
	ModeAuto   Mode = 0
	ModeAlways Mode = 1
	ModeNever  Mode = 2
)

func (Mode) IsEnabled

func (instance Mode) IsEnabled(support Support) bool

func (Mode) MarshalText

func (instance Mode) MarshalText() (text []byte, err error)

func (Mode) Set

func (instance Mode) Set(plain string) error

func (Mode) String

func (instance Mode) String() string

func (*Mode) UnmarshalText

func (instance *Mode) UnmarshalText(text []byte) error

type Support

type Support uint8
const (
	SupportNone    Support = 0
	SupportNative  Support = 1
	SupportAssumed Support = 2
)

func DetectSupportForWriter

func DetectSupportForWriter(w io.Writer) (prepared io.Writer, support Support, err error)

func (Support) IsSupported

func (instance Support) IsSupported() bool

func (Support) MarshalText

func (instance Support) MarshalText() (text []byte, err error)

func (Support) Set

func (instance Support) Set(plain string) error

func (Support) String

func (instance Support) String() string

func (*Support) UnmarshalText

func (instance *Support) UnmarshalText(text []byte) error

type SupportAssumptionDetection

type SupportAssumptionDetection func() bool

Jump to

Keyboard shortcuts

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