logging

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SystemAttribute = "serviceakasar/system"

Variables

This section is empty.

Functions

func Shorten

func Shorten(s string) string

Shorten 返回一个s的短前缀

func ShortenComponent

func ShortenComponent(component string) string

func StderrLogger

func StderrLogger(opts Options) *slog.Logger

Types

type LogHandler

type LogHandler struct {
	Write func(entry *protos.LogEntry)
	// contains filtered or unexported fields
}

func NewLogHandler

func NewLogHandler(w func(entry *protos.LogEntry), opts Options) *LogHandler

NewLogHandler w after w.Write(b), b will be put back to a sync.Pool, so do not continue hold a reference to b.

func (*LogHandler) Enabled

func (h *LogHandler) Enabled(_ context.Context, l slog.Level) bool

func (*LogHandler) Handle

func (h *LogHandler) Handle(ctx context.Context, r slog.Record) error

func (*LogHandler) WithAttrs

func (h *LogHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*LogHandler) WithGroup

func (h *LogHandler) WithGroup(name string) slog.Handler

type LogHandler2

type LogHandler2 struct {
	*slog.JSONHandler
	// contains filtered or unexported fields
}

func (*LogHandler2) Enabled

func (h *LogHandler2) Enabled(ctx context.Context, level slog.Level) bool

func (*LogHandler2) Handle

func (h *LogHandler2) Handle(ctx context.Context, r slog.Record) error

func (*LogHandler2) WithGroup

func (h *LogHandler2) WithGroup(name string) slog.Handler

type Options

type Options struct {
	App        string
	Deployment string
	Component  string
	Akasalet   string

	//Attrs []string
	Attrs []slog.Attr

	Level int32
}

type PrettyFormatter

type PrettyFormatter interface {
	Format(*protos.LogEntry) string
}

type PrettyPrinter

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

PrettyPrinter pretty prints log entries to json string.

func NewPrettyPrinter

func NewPrettyPrinter() *PrettyPrinter

func (*PrettyPrinter) Format

func (p *PrettyPrinter) Format(entry *protos.LogEntry) string

Jump to

Keyboard shortcuts

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