log

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

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(scout.LogSeverityAttribute)
	LogMessageKey  = attribute.Key(scout.LogMessageAttribute)
)

Functions

func DisableOutput

func DisableOutput()

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

func Init

func Init()

Init configures logrus to ship logs to Scout

func SubmitFrontendConsoleMessages

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

func SubmitHTTPLog

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

func SubmitVercelLogs

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

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

type Message

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

func ParseConsoleMessages

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

type MessageTrace

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

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

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

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

type VercelLog

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

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