logutils

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugKeyBinSalt        = "bin_salt"      // Forces the usage of constant as salt (only for maintainers).
	DebugKeyGoModSalt      = "gomod_salt"    // Display logs related to the salt computation from the go.mod file.
	DebugKeyConfigReader   = "config_reader" // Display logs related to configuration loading.
	DebugKeyEmpty          = ""
	DebugKeyEnabledLinters = "enabled_linters" // Display logs related to the enabled linters inside the [lintersdb.Manager].
	DebugKeyExec           = "exec"            // Display logs related to the lock file.
	DebugKeyGoEnv          = "goenv"           // Display logs related to [goenv.Env].
	DebugKeyLintersContext = "linters_context" // Display logs related to the package analysis context (not related to [context.Context]).
	DebugKeyLintersDB      = "lintersdb"       // Display logs related to the linters/formatters loading.
	DebugKeyLoader         = "loader"          // Display logs related to package loading (including `go/packages` internal debugging).
	DebugKeyPkgCache       = "pkgcache"        // Display logs related to cache.
	DebugKeyRunner         = "runner"          // Display logs related to the linter runner.
	DebugKeyStopwatch      = "stopwatch"       // Display logs related to the stopwatch of the cache.
	DebugKeyTest           = "test"            // Display debug logs during integration tests.
)
View Source
const (
	DebugKeyCheckstylePrinter  = "checkstyle_printer"
	DebugKeyCodeClimatePrinter = "codeclimate_printer"
	DebugKeySarifPrinter       = "sarif_printer"
	DebugKeyTabPrinter         = "tab_printer"
	DebugKeyTeamCityPrinter    = "teamcity_printer"
	DebugKeyTextPrinter        = "text_printer"
)

Printers.

View Source
const (
	DebugKeyExclusionPaths      = "exclusion_paths"
	DebugKeyExclusionRules      = "exclusion_rules"
	DebugKeyFilenameUnadjuster  = "filename_unadjuster"
	DebugKeyGeneratedFileFilter = "generated_file_filter" // Debugs a filter excluding autogenerated source code.
	DebugKeyInvalidIssue        = "invalid_issue"
	DebugKeyMaxFromLinter       = "max_from_linter"
	DebugKeyMaxSameIssues       = "max_same_issues"
	DebugKeyNolintFilter        = "nolint_filter" // Debugs a filter excluding issues by `//nolint` comments.
	DebugKeyPathAbsoluter       = "path_absoluter"
	DebugKeyPathPrettifier      = "path_prettifier"
	DebugKeyPathRelativity      = "path_relativity"
	DebugKeySeverityRules       = "severity_rules"
	DebugKeySourceCode          = "source_code"
)

Processors.

View Source
const (
	DebugKeyGoAnalysis = "goanalysis"

	DebugKeyGoAnalysisAnalyze     = DebugKeyGoAnalysis + "/analyze"
	DebugKeyGoAnalysisIssuesCache = DebugKeyGoAnalysis + "/issues/cache"
	DebugKeyGoAnalysisMemory      = DebugKeyGoAnalysis + "/memory"

	DebugKeyGoAnalysisFacts        = DebugKeyGoAnalysis + "/facts"
	DebugKeyGoAnalysisFactsCache   = DebugKeyGoAnalysisFacts + "/cache"
	DebugKeyGoAnalysisFactsExport  = DebugKeyGoAnalysisFacts + "/export"
	DebugKeyGoAnalysisFactsInherit = DebugKeyGoAnalysisFacts + "/inherit"
)

Analysis.

View Source
const (
	DebugKeyFormatter        = "formatter"         // Display logs from the shared logger for formatters.
	DebugKeyFormattersOutput = "formatters_output" // Display logs from formatters themselves.
	DebugKeyLinter           = "linter"            // Display logs from the shared logger for linters.
	DebugKeyLintersOutput    = "linters_output"    // Display logs from linters themselves.

	DebugKeyForbidigo   = "forbidigo"   // Debugs `forbidigo` linter.
	DebugKeyGoCritic    = "gocritic"    // Debugs `gocritic` linter.
	DebugKeyGovet       = "govet"       // Debugs `govet` linter.
	DebugKeyRevive      = "revive"      // Debugs `revive` linter.
	DebugKeyStaticcheck = "staticcheck" // Debugs `staticcheck` linter.
)

Linters and Formatters.

View Source
const EnvTestRun = "GL_TEST_RUN"

EnvTestRun value: "1"

Variables

Functions

func DisableColors added in v2.2.0

func DisableColors(disable bool)

func HaveDebugTag

func HaveDebugTag(tag string) bool

func IsVerbose

func IsVerbose() bool

func SetupVerboseLog

func SetupVerboseLog(log Log, isVerbose bool)

Types

type DebugFunc

type DebugFunc func(format string, args ...any)

func Debug

func Debug(tag string) DebugFunc

type Log

type Log interface {
	Fatalf(format string, args ...any)
	Panicf(format string, args ...any)
	Errorf(format string, args ...any)
	Warnf(format string, args ...any)
	Infof(format string, args ...any)

	Child(name string) Log
	SetLevel(level LogLevel)
}

type LogLevel

type LogLevel int
const (
	// LogLevelDebug Debug messages, write to debug logs only by logutils.Debug.
	LogLevelDebug LogLevel = 0

	// LogLevelInfo Information messages, don't write too many messages,
	// only useful ones: they are shown when running with -v.
	LogLevelInfo LogLevel = 1

	// LogLevelWarn Hidden errors: non-critical errors: work can be continued, no need to fail whole program;
	// tests will crash if any warning occurred.
	LogLevelWarn LogLevel = 2

	// LogLevelError Only not hidden from user errors: whole program failing, usually
	// error logging happens in 1-2 places: in the "main" function.
	LogLevelError LogLevel = 3
)

type MockLog

type MockLog struct {
	mock.Mock
}

func NewMockLog

func NewMockLog() *MockLog

func (*MockLog) Child

func (m *MockLog) Child(name string) Log

func (*MockLog) Errorf

func (m *MockLog) Errorf(format string, args ...any)

func (*MockLog) Fatalf

func (m *MockLog) Fatalf(format string, args ...any)

func (*MockLog) Infof

func (m *MockLog) Infof(format string, args ...any)

func (*MockLog) OnErrorf

func (m *MockLog) OnErrorf(format string, args ...any) *MockLog

func (*MockLog) OnFatalf

func (m *MockLog) OnFatalf(format string, args ...any) *MockLog

func (*MockLog) OnInfof

func (m *MockLog) OnInfof(format string, args ...any) *MockLog

func (*MockLog) OnPanicf

func (m *MockLog) OnPanicf(format string, args ...any) *MockLog

func (*MockLog) OnWarnf

func (m *MockLog) OnWarnf(format string, args ...any) *MockLog

func (*MockLog) Panicf

func (m *MockLog) Panicf(format string, args ...any)

func (*MockLog) SetLevel

func (m *MockLog) SetLevel(level LogLevel)

func (*MockLog) Warnf

func (m *MockLog) Warnf(format string, args ...any)

type StderrLog

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

func NewStderrLog

func NewStderrLog(name string) *StderrLog

func (StderrLog) Child

func (sl StderrLog) Child(name string) Log

func (StderrLog) Debugf

func (sl StderrLog) Debugf(format string, args ...any)

func (StderrLog) Errorf

func (sl StderrLog) Errorf(format string, args ...any)

func (StderrLog) Fatalf

func (sl StderrLog) Fatalf(format string, args ...any)

func (StderrLog) Infof

func (sl StderrLog) Infof(format string, args ...any)

func (StderrLog) Panicf

func (sl StderrLog) Panicf(format string, args ...any)

func (*StderrLog) SetLevel

func (sl *StderrLog) SetLevel(level LogLevel)

func (StderrLog) Warnf

func (sl StderrLog) Warnf(format string, args ...any)

Jump to

Keyboard shortcuts

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