hlog

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 14 Imported by: 25

Documentation

Index

Constants

View Source
const LogAttributeValueLengthLimit = 2 << 15
View Source
const TimestampFormat = "2006-01-02T15:04:05.000Z"
View Source
const TimestampFormatNano = "2006-01-02T15:04:05.999999999Z"

Variables

View Source
var (
	LogSeverityKey = attribute.Key(highlight.LogSeverityAttribute)
	LogMessageKey  = attribute.Key(highlight.LogMessageAttribute)
)

Functions

func DisableOutput added in v0.9.4

func DisableOutput()

DisableOutput turns off stdout / stderr output from logrus, in case another logger is already used.

func FormatLogAttributes added in v0.10.2

func FormatLogAttributes(ctx context.Context, k string, v interface{}) map[string]string

func Init added in v0.9.4

func Init()

Init configures logrus to ship logs to highlight.io

func SubmitFrontendConsoleMessages added in v0.8.12

func SubmitFrontendConsoleMessages(ctx context.Context, projectID int, sessionSecureID string, messages string) error

func SubmitHTTPLog added in v0.9.10

func SubmitHTTPLog(ctx context.Context, projectID int, lg Log) error

func SubmitVercelLogs added in v0.8.12

func SubmitVercelLogs(ctx context.Context, projectID int, logs []VercelLog)

Types

type Hook

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

Hook is a logrus hook that adds logs to the active span as events.

func NewHook

func NewHook(opts ...Option) *Hook

NewHook returns a logrus hook.

func (*Hook) Fire

func (hook *Hook) Fire(entry *logrus.Entry) error

Fire is a logrus hook that is fired on a new log entry.

func (*Hook) Levels

func (hook *Hook) Levels() []logrus.Level

Levels returns logrus levels on which this hook is fired.

type Log added in v0.9.10

type Log struct {
	Message    string `json:"message"`
	Timestamp  string `json:"timestamp"`
	Level      string `json:"level"`
	Attributes map[string]string
}

type Message added in v0.8.12

type Message struct {
	Type       string         `json:"type"`
	Trace      []MessageTrace `json:"trace"`
	Value      []string       `json:"value"`
	Attributes map[string]any `json:"attributes"`
	Time       int64          `json:"time"`
}

func ParseConsoleMessages added in v0.8.12

func ParseConsoleMessages(messages string) ([]*Message, error)

type MessageTrace added in v0.9.3

type MessageTrace struct {
	ColumnNumber any    `json:"columnNumber"`
	LineNumber   any    `json:"lineNumber"`
	FileName     string `json:"fileName"`
	FunctionName string `json:"functionName,omitempty"`
	Source       string `json:"source"`
}

type Messages added in v0.8.12

type Messages struct {
	Messages []Message `json:"messages"`
}

type Option

type Option func(h *Hook)

Option applies a configuration to the given config.

func WithLevels

func WithLevels(levels ...logrus.Level) Option

WithLevels sets the logrus logging levels on which the hook is fired.

The default is all levels between logrus.PanicLevel and logrus.WarnLevel inclusive.

type PinoLog added in v0.9.12

type PinoLog struct {
	Level    uint8  `json:"level"`
	Time     int64  `json:"time"`
	PID      int64  `json:"pid"`
	Hostname string `json:"hostname"`
	Message  string `json:"msg"`
}

type PinoLogs added in v0.9.12

type PinoLogs struct {
	Logs []*PinoLog `json:"logs"`
}

type VercelLog added in v0.8.12

type VercelLog struct {
	Id           string `json:"id"`
	Message      string `json:"message"`
	Timestamp    int64  `json:"timestamp"`
	Source       string `json:"source"`
	ProjectId    string `json:"projectId"`
	DeploymentId string `json:"deploymentId"`
	BuildId      string `json:"buildId"`
	Host         string `json:"host"`

	Type       string `json:"type"`
	Entrypoint string `json:"entrypoint"`

	RequestId   string      `json:"requestId"`
	StatusCode  int64       `json:"statusCode"`
	Destination string      `json:"destination"`
	Path        string      `json:"path"`
	Proxy       VercelProxy `json:"proxy"`
}

type VercelProxy added in v0.8.12

type VercelProxy struct {
	Timestamp   int64    `json:"timestamp"`
	Method      string   `json:"method"`
	Scheme      string   `json:"scheme"`
	Host        string   `json:"host"`
	Path        string   `json:"path"`
	UserAgent   []string `json:"userAgent"`
	Referer     string   `json:"referer"`
	StatusCode  int64    `json:"statusCode"`
	ClientIp    string   `json:"clientIp"`
	Region      string   `json:"region"`
	CacheId     string   `json:"cacheId"`
	VercelCache string   `json:"vercelCache"`
}

Jump to

Keyboard shortcuts

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