glogger

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorPrint added in v0.0.5

func ColorPrint(str string, mode ColorPrintMode, bc PrintColor, tc PrintColor)

func NewBaseLogger

func NewBaseLogger(writer GLogWriterGetter, options *GLogOptions) *baseLogger

Types

type ColorPrintMode added in v0.0.5

type ColorPrintMode int
const (
	// ColorPrintModeDefault 终端默认设置
	ColorPrintModeDefault ColorPrintMode = 0
	// ColorPrintModeHighlight 高亮显示
	ColorPrintModeHighlight ColorPrintMode = 1
	// ColorPrintModeUnderline 使用下划线
	ColorPrintModeUnderline ColorPrintMode = 4
	// ColorPrintModeFlash 闪烁
	ColorPrintModeFlash ColorPrintMode = 5
	// ColorPrintModeReverse 反白
	ColorPrintModeReverse ColorPrintMode = 7
	// ColorPrintModeHidden 不可见
	ColorPrintModeHidden ColorPrintMode = 8
)

type GLog

type GLog struct {
	Level LogLevel
	Tag   string
	Date  time.Time
	Log   any
}

type GLogOptions

type GLogOptions struct {
	Prefix string   `json:"prefix"`
	Level  LogLevel `json:"level"`
}

type GLogWriter

type GLogWriter interface {
	Write(log *GLog)
}

type GLogWriterGetter

type GLogWriterGetter func() GLogWriter

type GLogger

type GLogger interface {
	Log(level LogLevel, tag string, data any)
	Info(tag string, data any)
	Debug(tag string, data any)
	Warn(tag string, data any)
	Error(tag string, data any)
}

func NewConsoleLogger

func NewConsoleLogger(options *GLogOptions) GLogger

type GWSLogWriter

type GWSLogWriter interface {
	ID() string
	GLogger
}

type GWSLogger

type GWSLogger interface {
	http.Handler
	GLogger
}

func NewGWSLogger

func NewGWSLogger(ctx context.Context, jwt utils.JwtToken) GWSLogger

type LogLevel

type LogLevel string
const (
	LogLevelAll   LogLevel = "all"
	LogLevelInfo  LogLevel = "info"
	LogLevelDebug LogLevel = "debug"
	LogLevelWarn  LogLevel = "warn"
	LogLevelError LogLevel = "error"
)

type PrintColor added in v0.0.5

type PrintColor int
const (
	// PrintTextColorBlack 黑色
	PrintTextColorBlack PrintColor = 30
	// PrintTextColorRed 红色
	PrintTextColorRed PrintColor = 31
	// PrintTextColorGreen 绿色
	PrintTextColorGreen PrintColor = 32
	// PrintTextColorYellow 黄色
	PrintTextColorYellow PrintColor = 33
	// PrintTextColorBlue 蓝色
	PrintTextColorBlue PrintColor = 34
	// PrintTextColorPurplishRed 紫红色
	PrintTextColorPurplishRed PrintColor = 35
	// PrintTextColorTurquoise 青蓝色
	PrintTextColorTurquoise PrintColor = 36
	// PrintTextColorWhite 白色
	PrintTextColorWhite PrintColor = 37

	// PrintBackgroundBlack 色黑
	PrintBackgroundBlack PrintColor = 40
	// PrintBackgroundRed 红色
	PrintBackgroundRed PrintColor = 41
	// PrintBackgroundGreen 绿色
	PrintBackgroundGreen PrintColor = 42
	// PrintBackgroundYellow 黄色
	PrintBackgroundYellow PrintColor = 43
	// PrintBackgroundBlue 蓝色
	PrintBackgroundBlue PrintColor = 44
	// PrintBackgroundPurplishRed 紫红色
	PrintBackgroundPurplishRed PrintColor = 35
	// PrintBackgroundTurquoise 青蓝色
	PrintBackgroundTurquoise PrintColor = 46
	// PrintBackgroundWhite 白色
	PrintBackgroundWhite PrintColor = 47
)

type WSEventData

type WSEventData struct {
	Code    int    `json:"code"`
	Msg     string `json:"msg"`
	Content any    `json:"content,omitempty"`
}

func NewEventError

func NewEventError(msg string) *WSEventData

func NewWSEventData

func NewWSEventData(data any) *WSEventData

type WSEventDataPk

type WSEventDataPk struct {
	Event string `json:"event"`
	Data  any    `json:"data"`
}

Jump to

Keyboard shortcuts

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