logger

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	LogDomain = "lowcode_func_log"

	NormalLog      = 1
	AggregationLog = 2

	LogLevelError = 4
	LogLevelWarn  = 5
	LogLevelInfo  = 6

	LogCountLimit     = 10000
	LogLengthLimit    = 10000
	LogLengthLimitTip = `\n... The log has been truncated because it exceeds the length limit.`
	LogCountLimitTip  = `The log has been discarded because it exceeded the limit of  10000`
)

Variables

This section is empty.

Functions

func CompressForDeflate

func CompressForDeflate(b []byte) (string, error)

func Send

func Send(ctx context.Context, l *Logger)

func SetFunctionLoggerExtraToCtx

func SetFunctionLoggerExtraToCtx(ctx context.Context, extra FunctionLoggerExtra) context.Context

func SetLogger

func SetLogger(ctx context.Context, l *Logger) context.Context

func TimeNowMils

func TimeNowMils() int64

Types

type ExtraInfo

type ExtraInfo struct {
	FunctionVersionID int64        `json:"functionVersionID"`
	SourceLabel       structs.I18n `json:"sourceLabel"`
	ObjectLabel       structs.I18n `json:"objectLabel"`
	TriggerTimeCost   int64        `json:"triggerTimeCost"`
	RuntimeCost       int64        `json:"runtimeCost"`
}

type FormatLog added in v0.0.29

type FormatLog struct {
	Level         int    `json:"level"`           // 日志级别, 4-error,5-warn,6-info
	EventID       string `json:"event_id"`        // 事件 ID,可观测需要
	FunctionAPIID string `json:"function_api_id"` // 函数 API ID
	LogID         string `json:"log_id"`          // 日志 ID,事件编号与日志编号有一一对应关系
	Timestamp     int64  `json:"timestamp"`       // 时间
	Message       string `json:"message"`         // 用户的日志内容,SDK 会对超长日志截断
	TenantID      int64  `json:"tenant_id"`       // 租户 ID
	TenantType    int64  `json:"tenant_type"`     // 租户 ID
	Namespace     string `json:"namespace"`       // 命名空间
}

type FunctionLoggerExtra

type FunctionLoggerExtra struct {
	FunctionLabel     structs.I18n `json:"functionLabel"`
	SourceID          string       `json:"sourceID"`
	SourceLabel       structs.I18n `json:"sourceLabel"`
	FunctionVersionID int64        `json:"functionVersionID"`
	ObjectLabel       structs.I18n `json:"objectLabel"`
	InstanceID        int64        `json:"instanceID"`
	StartTriggerTime  int64        `json:"startTriggerTime"`
}

FunctionLoggerExtra Only Logger 使用的参数

type I18nTag

type I18nTag struct {
	Key   string       `json:"key"`
	Value structs.I18n `json:"value"`
}

type Log

type Log struct {
	Domain     string `json:"domain"`
	Type       int    `json:"type"`
	Level      int    `json:"level"`
	CreateTime int64  `json:"createTime"`
	RequestID  string `json:"RequestID"`
	Sequence   int64  `json:"sequence"`
	Content    string `json:"content"`

	Tags      []Tag     `json:"tags"`
	TagsI18n  []I18nTag `json:"tagsI18n"`
	ExtraInfo ExtraInfo `json:"extraInfo"`
}

type Logger

type Logger struct {
	RequestID string
	// contains filtered or unexported fields
}

func GetLogger

func GetLogger(ctx context.Context) *Logger

func NewConsoleLogger added in v0.0.23

func NewConsoleLogger(ctx context.Context) *Logger

func NewLogger

func NewLogger(ctx context.Context) *Logger

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

type Tag

type Tag struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Jump to

Keyboard shortcuts

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