CubeLog

package module
v0.0.0-...-8e4d082 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: Apache-2.0, BSD-2-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyRequestID      contextKey = "request_id"
	KeyAction         contextKey = "action"
	KeyCaller         contextKey = "caller"
	KeyCallee         contextKey = "callee"
	KeyCallerIp       contextKey = "caller_ip"
	KeyCalleeEndpoint contextKey = "callee_endpoint"
	KeyCalleeAction   contextKey = "callee_action"
	KeyRetCode        contextKey = "retcode"
	KeyCostTime       contextKey = "cost_time"

	KeyNamespace contextKey = "namespace"

	KeyInstanceId contextKey = "instance_id"

	KeyAppID contextKey = "app_id"

	KeyModuleVersion contextKey = "version"
	KeyContainerId   contextKey = "container_id"

	KeyRegion        contextKey = "region"
	KeyCluster       contextKey = "cluster"
	KeyCalleeCluster contextKey = "callee_cluster"
	KeyFunctionType  contextKey = "function_type"
	KeyDeployMode    contextKey = "deploy_mode"
	KeyInstanceType  contextKey = "instance_type"
)
View Source
const (
	KeyAlarmType contextKey = "alarm_type"
	KeyAlarmName contextKey = "alarm_name"
)
View Source
const (
	TextFormat logFormat = iota
	JSONFormat
)

Variables

View Source
var (
	CallerPrettyfier func(*runtime.Frame) (file string)
)
View Source
var LocalIP string

Functions

func Create

func Create(path string)

func Debug

func Debug(args ...interface{})

func Debugf

func Debugf(format string, args ...interface{})

func DisableLogMetric

func DisableLogMetric()

func EnableFileLog

func EnableFileLog()

func EnableLogMetric

func EnableLogMetric()

func EnableLongFilePath

func EnableLongFilePath()

func Error

func Error(args ...interface{})

func Errorf

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

func Fatal

func Fatal(args ...interface{})

func Fatalf

func Fatalf(format string, args ...interface{})

func GetModuleName

func GetModuleName() string

func Info

func Info(args ...interface{})

func Infof

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

func Init

func Init(cfg Config)

func SetCallerPrettyfier

func SetCallerPrettyfier(f func(*runtime.Frame) (file string))

func SetCluster

func SetCluster(c string)

func SetCustomFields

func SetCustomFields(fields Fields)

func SetLevel

func SetLevel(level LogLevel)

func SetLogFormat

func SetLogFormat(format logFormat)

func SetModuleName

func SetModuleName(n string)

func SetOutput

func SetOutput(w io.Writer)

func SetOutputLogger

func SetOutputLogger(l *Logger)

func SetRegion

func SetRegion(r Region)

func SetReportCaller

func SetReportCaller(b bool)

func SetSkipCallerDepth

func SetSkipCallerDepth(depth int)

func SetTraceOutput

func SetTraceOutput(w io.Writer)

func SetVersion

func SetVersion(version string)

func SuccinctCallerPath

func SuccinctCallerPath(f *runtime.Frame) string

func Trace

func Trace(trace *RequestTrace)

func Warn

func Warn(args ...interface{})

func Warnf

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

func WithRequestTrace

func WithRequestTrace(ctx context.Context, trace *RequestTrace) context.Context

Types

type BufferPool

type BufferPool interface {
	Put(buffer *bytes.Buffer)
	Get() *bytes.Buffer
}

type Config

type Config struct {
	Net Net

	Path string

	Count int

	Size int

	AsyncFlush string
	// contains filtered or unexported fields
}

type ConsoleWriter

type ConsoleWriter struct {
}

func (*ConsoleWriter) Write

func (w *ConsoleWriter) Write(v []byte) (int, error)

type DateType

type DateType uint8
const (
	DAY DateType = iota
	HOUR
)

type DateWriter

type DateWriter struct {
	// contains filtered or unexported fields
}

func NewDateWriter

func NewDateWriter(logpath, name string, dateType DateType, num int) *DateWriter

func (*DateWriter) Write

func (w *DateWriter) Write(v []byte) (int, error)

type Entry

type Entry struct {
	// contains filtered or unexported fields
}

func NewEntry

func NewEntry(logger *Logger) *Entry

func WithContext

func WithContext(ctx context.Context) *Entry

func WithFields

func WithFields(fields Fields) *Entry

func (*Entry) Debug

func (entry *Entry) Debug(v ...interface{})

func (*Entry) Debugf

func (entry *Entry) Debugf(format string, v ...interface{})

func (*Entry) Error

func (entry *Entry) Error(v ...interface{})

func (*Entry) Errorf

func (entry *Entry) Errorf(format string, v ...interface{})

func (*Entry) Fatal

func (entry *Entry) Fatal(v ...interface{})

func (*Entry) Fatalf

func (entry *Entry) Fatalf(format string, v ...interface{})

func (*Entry) GetFields

func (entry *Entry) GetFields() Fields

func (*Entry) Info

func (entry *Entry) Info(v ...interface{})

func (*Entry) Infof

func (entry *Entry) Infof(format string, v ...interface{})

func (*Entry) Warn

func (entry *Entry) Warn(v ...interface{})

func (*Entry) Warnf

func (entry *Entry) Warnf(format string, v ...interface{})

func (*Entry) WithContext

func (entry *Entry) WithContext(ctx context.Context) *Entry

func (*Entry) WithFields

func (entry *Entry) WithFields(fields Fields) *Entry

type ErrorCode

type ErrorCode int
const (
	CodeSuccess ErrorCode = iota
	CodeInternalError
	CodeInvalidParameter
	CodeInvalidParameterValue
	CodeAuthFailure
	CodeResourceNotFound
	CodeResourceUnavailable
	CodeUnauthorizedOperation
	CodeFailedOperation
	CodeUnsupportedOperation
	CodeLimitExceeded
	CodeResourceInUse
	CodeMissingParameter
	CodeResourceInsufficient
	CodeUnknownError
)

func (ErrorCode) String

func (s ErrorCode) String() string

type Fields

type Fields map[string]interface{}

export type Fields

func GetCustomFields

func GetCustomFields() Fields

type HourWriter

type HourWriter struct {
}

type LogLevel

type LogLevel uint8
const (
	DEBUG LogLevel = iota
	INFO
	WARN
	ERROR
	FATAL
	OFF
)

func GetLevel

func GetLevel() LogLevel

func StringToLevel

func StringToLevel(level string) LogLevel

func (*LogLevel) String

func (lv *LogLevel) String() string

type Logger

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

func GetDefaultLogger

func GetDefaultLogger() *Logger

func GetLogger

func GetLogger(name string) *Logger

func GetLoggerByName

func GetLoggerByName(name string) *Logger

func (*Logger) Debug

func (logger *Logger) Debug(v ...interface{})

func (*Logger) Debugf

func (logger *Logger) Debugf(format string, v ...interface{})

func (*Logger) EnableFileLog

func (logger *Logger) EnableFileLog()

func (*Logger) Error

func (logger *Logger) Error(v ...interface{})

func (*Logger) Errorf

func (logger *Logger) Errorf(format string, v ...interface{})

func (*Logger) Fatal

func (logger *Logger) Fatal(v ...interface{})

func (*Logger) Fatalf

func (logger *Logger) Fatalf(format string, v ...interface{})

func (*Logger) GetCustomFields

func (logger *Logger) GetCustomFields() Fields

func (*Logger) Info

func (logger *Logger) Info(v ...interface{})

func (*Logger) Infof

func (logger *Logger) Infof(format string, v ...interface{})

func (*Logger) IsConsoleWriter

func (logger *Logger) IsConsoleWriter() bool

func (*Logger) SetConsole

func (logger *Logger) SetConsole()

func (*Logger) SetCustomFields

func (logger *Logger) SetCustomFields(fields Fields)

func (*Logger) SetDayRoller

func (logger *Logger) SetDayRoller(logpath string, num int) error

func (*Logger) SetFileRoller

func (logger *Logger) SetFileRoller(logpath string, num int, sizeMB int) error

func (*Logger) SetHourRoller

func (logger *Logger) SetHourRoller(logpath string, num int) error

func (*Logger) SetLogFormat

func (logger *Logger) SetLogFormat(format logFormat)

func (*Logger) SetLogName

func (logger *Logger) SetLogName(name string)

func (*Logger) SetOutput

func (logger *Logger) SetOutput(w io.Writer)

func (*Logger) Warn

func (logger *Logger) Warn(v ...interface{})

func (*Logger) Warnf

func (logger *Logger) Warnf(format string, v ...interface{})

func (*Logger) WithContext

func (logger *Logger) WithContext(ctx context.Context) *Entry

func (*Logger) WithFields

func (logger *Logger) WithFields(fields Fields) *Entry

func (*Logger) WriteLog

func (l *Logger) WriteLog(msg []byte)

type Net

type Net string
const (
	CloudVpc     Net = "CloudVpc"
	CloudSupport Net = "CloudSupport"
)

type Region

type Region string
const (
	RegionGuangzhou     Region = "ap-guangzhou"
	RegionShanghai      Region = "ap-shanghai"
	RegionBeijing       Region = "ap-beijing"
	RegionHongKong      Region = "ap-hongkong"
	RegionChengdu       Region = "ap-chengdu"
	RegionIndia         Region = "ap-mumbai"
	RegionChongqing     Region = "ap-chongqing"
	RegionSeoul         Region = "ap-seoul"
	RegionSingapore     Region = "ap-singapore"
	RegionToronto       Region = "na-toronto"
	RegionSiliconValley Region = "na-siliconvalley"
	RegionFrankfurt     Region = "eu-frankfurt"
	RegionBangkok       Region = "ap-bangkok"
)

func (Region) String

func (r Region) String() string

type RemoteConfig

type RemoteConfig struct {
	EnableLocal string

	RetmoteLogAddr string
	RetmoteLogPort int

	ReqTimeout int
	// contains filtered or unexported fields
}

type RequestTrace

type RequestTrace struct {
	DestID         int64
	Region         string
	AppID          int64
	RequestID      string
	Action         string
	Qualifier      string
	InstanceID     string
	FunctionName   string
	Namespace      string
	VersionID      string
	Timestamp      time.Time
	Caller         string
	Callee         string
	CallerIP       string
	CalleeEndpoint string
	CalleeAction   string
	ErrorCode      ErrorCode
	SubErrorCode   string
	Cost           time.Duration
	RetCode        int64
	Version        string
	Cluster        string
	ContainerID    string
	ColdStart      float64
	Duration       int64
	ErrorSource    string
	CvmId          string
	Runtime        string
	CalleeCluster  string
	FunctionType   string
	DeployMode     string
	InstanceType   string
}

func GetTraceInfo

func GetTraceInfo(ctx context.Context) *RequestTrace

func (*RequestTrace) DeepCopy

func (rt *RequestTrace) DeepCopy() *RequestTrace

func (*RequestTrace) WithCallee

func (rt *RequestTrace) WithCallee(callee string) *RequestTrace

type RollFileWriter

type RollFileWriter struct {
	// contains filtered or unexported fields
}

func NewRollFileWriter

func NewRollFileWriter(logpath, name string, num, sizeMB int) *RollFileWriter

func (*RollFileWriter) Write

func (w *RollFileWriter) Write(v []byte) (int, error)

Directories

Path Synopsis
examples
log

Jump to

Keyboard shortcuts

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