log

package
v0.0.0-...-72835c4 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2023 License: MPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AccessAccepted = AccessStatus("accepted")
	AccessRejected = AccessStatus("rejected")
)

Variables

View Source
var (
	DNSQueried  = dnsStatus("got answer:")
	DNSCacheHit = dnsStatus("cache HIT:")
)
View Source
var (
	Severity_name = map[int32]string{
		0: "Unknown",
		1: "Error",
		2: "Warning",
		3: "Info",
		4: "Debug",
	}
	Severity_value = map[string]int32{
		"Unknown": 0,
		"Error":   1,
		"Warning": 2,
		"Info":    3,
		"Debug":   4,
	}
)

Enum value maps for Severity.

View Source
var File_common_log_log_proto protoreflect.FileDescriptor

Functions

func ContextWithAccessMessage

func ContextWithAccessMessage(ctx context.Context, accessMessage *AccessMessage) context.Context

func Record

func Record(msg Message)

Record writes a message into log stream.

func RegisterHandler

func RegisterHandler(handler Handler)

RegisterHandler registers a new handler as current log handler. Previous registered handler will be discarded.

Types

type AccessMessage

type AccessMessage struct {
	From   interface{}
	To     interface{}
	Status AccessStatus
	Reason interface{}
	Email  string
	Detour string
}

func AccessMessageFromContext

func AccessMessageFromContext(ctx context.Context) *AccessMessage

func (*AccessMessage) String

func (m *AccessMessage) String() string

type AccessStatus

type AccessStatus string

type DNSLog

type DNSLog struct {
	Server  string
	Domain  string
	Result  []net.IP
	Status  dnsStatus
	Elapsed time.Duration
	Error   error
}

func (*DNSLog) String

func (l *DNSLog) String() string

type GeneralMessage

type GeneralMessage struct {
	Severity Severity
	Content  interface{}
}

GeneralMessage is a general log message that can contain all kind of content.

func (*GeneralMessage) String

func (m *GeneralMessage) String() string

String implements Message.

type Handler

type Handler interface {
	Handle(msg Message)
}

Handler is the interface for log handler.

func NewLogger

func NewLogger(logWriterCreator WriterCreator) Handler

NewLogger returns a generic log handler that can handle all type of messages.

type Message

type Message interface {
	String() string
}

Message is the interface for all log messages.

type Severity

type Severity int32
const (
	Severity_Unknown Severity = 0
	Severity_Error   Severity = 1
	Severity_Warning Severity = 2
	Severity_Info    Severity = 3
	Severity_Debug   Severity = 4
)

func (Severity) Descriptor

func (Severity) Descriptor() protoreflect.EnumDescriptor

func (Severity) Enum

func (x Severity) Enum() *Severity

func (Severity) EnumDescriptor deprecated

func (Severity) EnumDescriptor() ([]byte, []int)

Deprecated: Use Severity.Descriptor instead.

func (Severity) Number

func (x Severity) Number() protoreflect.EnumNumber

func (Severity) String

func (x Severity) String() string

func (Severity) Type

type Writer

type Writer interface {
	Write(string) error
	io.Closer
}

Writer is the interface for writing logs.

type WriterCreator

type WriterCreator func() Writer

WriterCreator is a function to create LogWriters.

func CreateFileLogWriter

func CreateFileLogWriter(path string) (WriterCreator, error)

CreateFileLogWriter returns a LogWriterCreator that creates LogWriter for the given file.

func CreateStderrLogWriter

func CreateStderrLogWriter() WriterCreator

CreateStderrLogWriter returns a LogWriterCreator that creates LogWriter for stderr.

func CreateStdoutLogWriter

func CreateStdoutLogWriter() WriterCreator

CreateStdoutLogWriter returns a LogWriterCreator that creates LogWriter for stdout.

Jump to

Keyboard shortcuts

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