checks

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Register = registry.Register
	RunCheck = registry.RunCheck
	Shutup   = registry.Shutup
	HasTag   = registry.HasTag
)

Functions

func NewCheckRegistry

func NewCheckRegistry() *checkRegistry

Types

type Checker

type Checker interface {
	Check(ctx context.Context) []Message
}

type Message

type Message struct {
	ID     string
	Type   Type
	Object any
	Hint   string
	Text   string
}

func Critical

func Critical(ID, text string, object any, hint ...string) Message

func Criticalf

func Criticalf(ID, text string, object any, hint string, args ...any) Message

func Debug

func Debug(ID, text string, object any, hint ...string) Message

func Debugf

func Debugf(ID, text string, object any, hint string, args ...any) Message

func Error

func Error(ID, text string, object any, hint ...string) Message

func Errorf

func Errorf(ID, text string, object any, hint string, args ...any) Message

func Info

func Info(ID, text string, object any, hint ...string) Message

func Infof

func Infof(ID, text string, object any, hint string, args ...any) Message

func Warning

func Warning(ID, text string, object any, hint ...string) Message

func Warningf

func Warningf(ID, text string, object any, hint string, args ...any) Message

func (Message) Is

func (m Message) Is(other Message) bool

Is checks if the message is of the same type and ID as another message.

It is used to compare messages for equality, ignoring the text and object fields.

It should still compare as true when it is compared to a message called with Message.New().

func (Message) IsSerious

func (m Message) IsSerious() bool

IsSerious checks if the message is of a serious type (ERROR or higher). It is used to determine if the message should be treated as a serious issue

If, for any reason, the seriousness comparison needs to be changed, it can be done by changing the value of SERIOUS_TYPE.

func (Message) New

func (m Message) New(object any, hint ...string) Message

New creates a new message with the same ID and type as the original message,

but with a new object and an optional hint.

It is used to create a new message with the same ID and type as an existing message, but with a different object and/or hint.

This is useful when you want to create global messages that can be reused with different objects or hints, while still keeping the same ID and type.

Any Message created with this method will still compare as equal when calling Message.Is.

func (Message) Silenced

func (m Message) Silenced(ctx context.Context) bool

Silenced checks if the message is silenced or not.

A message is silenced if its ID is in the registry's silenced list, or if its type (analogous to logger's log level) is lower than the current logger level.

func (Message) String

func (m Message) String(ctx context.Context) string

String returns a string representation of the message. It includes the ID, type, object type (if any), text, and hint (if any).

type Tag

type Tag string
const (
	TagSettings Tag = "settings"
	TagSecurity Tag = "security"
	TagCommands Tag = "commands"
	TagModels   Tag = "models"
)

type Type

type Type = logger.LogLevel
const (
	CRITICAL Type = logger.CRIT
	ERROR    Type = logger.ERR
	WARNING  Type = logger.WRN
	INFO     Type = logger.INF
	DEBUG    Type = logger.DBG

	SERIOUS_TYPE = ERROR
)

type TypeStringer

type TypeStringer interface {
	TypeString() string
}

type USELESS

type USELESS = struct{} // helps with registering at global variable scope

Jump to

Keyboard shortcuts

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