xlog

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(debug bool, hooks ...Hook) *zap.Logger

func NewWithConfig added in v0.0.2

func NewWithConfig(opts ...Option) *zap.Logger

NewWithConfig creates a logger with configuration options

Types

type Config added in v0.0.2

type Config struct {
	Debug    bool
	Hooks    []Hook
	Level    zapcore.Level
	Encoding string // "json" or "console"
}

Config is the logger configuration

type Hook

type Hook interface {
	Process(entry zapcore.Entry) error
}

Hook can process log before output

type Hooks added in v0.0.2

type Hooks []Hook

Hooks is a slice of Hook that implements Hook interface

func (Hooks) Process added in v0.0.2

func (h Hooks) Process(entry zapcore.Entry) error

Process calls each hook in sequence

type MsgText

type MsgText struct {
	Content string `json:"content"`
}

MsgText is text message api model

type Option added in v0.0.2

type Option func(*Config)

Option configures the logger

func WithDebug added in v0.0.2

func WithDebug(debug bool) Option

WithDebug sets debug mode

func WithEncoding added in v0.0.2

func WithEncoding(encoding string) Option

WithEncoding sets the encoding format

func WithHooks added in v0.0.2

func WithHooks(hooks ...Hook) Option

WithHooks adds hooks

func WithLevel added in v0.0.2

func WithLevel(level zapcore.Level) Option

WithLevel sets the log level

type RobotMsg

type RobotMsg struct {
	MsgType string  `json:"msgtype"`
	Text    MsgText `json:"text"`
}

RobotMsg is message api model

type WeworkSender

type WeworkSender struct {
	BaseURL  string `default:"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key="`
	DebugKey string
	WarnKey  string
	ErrorKey string
}

WeworkSender can send notification to wechat work.

func (WeworkSender) Process

func (s WeworkSender) Process(entry zapcore.Entry) error

func (WeworkSender) SendRobotMsg

func (s WeworkSender) SendRobotMsg(key, content string) error

SendRobotMsg send robot message by wechat work web api

Jump to

Keyboard shortcuts

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