commonutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDebug = "DEBUG"
	LevelInfo  = "INFO"
	LevelWarn  = "WARN"
	LevelError = "ERROR"

	LogPrefix = "SERVER_ON_GNET"
)

Variables

This section is empty.

Functions

func SetLogger

func SetLogger(newLogger Logger)

Types

type CodecEmpty

type CodecEmpty struct{}

func (*CodecEmpty) Decode

func (ce *CodecEmpty) Decode(c gnet.Conn) ([]byte, error)

func (*CodecEmpty) Encode

func (ce *CodecEmpty) Encode(c gnet.Conn, buf []byte) ([]byte, error)

type DefaultLogger

type DefaultLogger struct{}

func (*DefaultLogger) Debugf

func (l *DefaultLogger) Debugf(ctx context.Context, format string, args ...interface{})

func (*DefaultLogger) Errorf

func (l *DefaultLogger) Errorf(ctx context.Context, format string, args ...interface{})

func (*DefaultLogger) Infof

func (l *DefaultLogger) Infof(ctx context.Context, format string, args ...interface{})

func (*DefaultLogger) Warnf

func (l *DefaultLogger) Warnf(ctx context.Context, format string, args ...interface{})

type LogData

type LogData struct {
	Prefix  string `json:"prefix"`
	Time    string `json:"time"`
	Level   string `json:"level"`
	Content string `json:"content"`
}

func (*LogData) EncodeToStr

func (ld *LogData) EncodeToStr() (string, error)

type Logger

type Logger interface {
	Debugf(ctx context.Context, format string, args ...interface{})
	Infof(ctx context.Context, format string, args ...interface{})
	Warnf(ctx context.Context, format string, args ...interface{})
	Errorf(ctx context.Context, format string, args ...interface{})
}

func GetLogger

func GetLogger() Logger

Jump to

Keyboard shortcuts

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