e4_log

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

README

  • 输出的格式: "timestamp", "host", "application", "component", "log_level", "thread_name", "extend", "msg"
  • JSON格式
{
  "timestamp": "2022-08-31T14:36:57+08:00",
  "host": "8.8.9.8",
  "application": "APPLICATION",
  "component": "COMPONENT",
  "log_level": "DEBUG",
  "thread_name": "THREAD_NAME",
  "extend": {
    "key": "value"
  },
  "msg": "This is Message"
}
require (
	github.com/believems/e4-log v0.0.3
)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var E4LogFields = []string{"timestamp", "host", "application", "component", "log_level", "thread_name", "extend", "msg"}

Functions

func CheckFields

func CheckFields(fields ...string) bool

func CheckMapKey

func CheckMapKey(checkedMap map[string]interface{}) bool

func Contains

func Contains[T comparable](s []T, e T) bool

Types

type E4Extend

type E4Extend map[string]interface{}

func (*E4Extend) JsonString

func (extend *E4Extend) JsonString() (string, error)

func (*E4Extend) String

func (extend *E4Extend) String() (string, error)

type E4Log

type E4Log struct {
	Timestamp   time.Time `json:"timestamp"`   //时间戳
	Host        string    `json:"host"`        //主机地址
	Application string    `json:"application"` //组件
	Component   string    `json:"component"`   //模块
	LogLevel    string    `json:"log_level"`   //日志级别
	ThreadName  string    `json:"thread_name"` //进程名称
	Extend      E4Extend  `json:"extend"`      //扩展属性
	Msg         string    `json:"msg"`         //消息体
}

func NewE4Log

func NewE4Log() *E4Log

func ParseJSON

func ParseJSON(jsonStr string) (*E4Log, error)

func (*E4Log) ExampleLine

func (e4log *E4Log) ExampleLine() string

func (*E4Log) JSon

func (e4log *E4Log) JSon() string

func (*E4Log) MarshalJSON

func (e4log *E4Log) MarshalJSON() ([]byte, error)

func (*E4Log) String

func (e4log *E4Log) String() string

func (*E4Log) StringMap

func (e4log *E4Log) StringMap() (map[string]interface{}, error)

Jump to

Keyboard shortcuts

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