web

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package web is the web server of easeprobe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStructuredLogger added in v1.5.0

func NewStructuredLogger(logger *logrus.Logger) func(next http.Handler) http.Handler

NewStructuredLogger returns a new StructuredLogger

func Server

func Server()

Server is the http server

func SetProbers

func SetProbers(p []probe.Prober)

SetProbers set the probers

Types

type AccessLog added in v1.5.0

type AccessLog struct {
	RemoteAddr string `json:"remote_addr"`
	UserID     string `json:"user_id"`
	Time       string `json:"time"`
	Method     string `json:"method"`
	Request    string `json:"request"`
	Status     string `json:"status"`
	Bytes      string `json:"bytes"`
	Elapsed    string `json:"elapsed"`
	Referrer   string `json:"referrer"`
	UserAgent  string `json:"user_agent"`
	Stack      string `json:"stack"`
	Panic      string `json:"panic"`
}

AccessLog is the default access log format

func (AccessLog) String added in v1.5.0

func (a AccessLog) String() string

type PlainFormatter added in v1.5.0

type PlainFormatter struct {
	TimestampFormat string
	LevelDesc       []string
}

PlainFormatter is a plain text formatter

func (*PlainFormatter) Format added in v1.5.0

func (f *PlainFormatter) Format(entry *logrus.Entry) ([]byte, error)

Format formats the log entry

type StructuredLogger added in v1.5.0

type StructuredLogger struct {
	Logger *logrus.Logger
}

StructuredLogger is a simple, but powerful implementation of a custom structured logger backed on logrus.

func (*StructuredLogger) NewLogEntry added in v1.5.0

func (l *StructuredLogger) NewLogEntry(r *http.Request) middleware.LogEntry

NewLogEntry creates a new logrus.Entry from the request

type StructuredLoggerEntry added in v1.5.0

type StructuredLoggerEntry struct {
	Logger    *logrus.Logger
	AccessLog AccessLog
}

StructuredLoggerEntry is a logrus.Entry with some additional fields

func (*StructuredLoggerEntry) Panic added in v1.5.0

func (l *StructuredLoggerEntry) Panic(v interface{}, stack []byte)

Panic is a convenience method for Logrus

func (*StructuredLoggerEntry) Write added in v1.5.0

func (l *StructuredLoggerEntry) Write(status, bytes int, header http.Header, elapsed time.Duration, extra interface{})

Write is method for Status Bytes and Elapsed

Jump to

Keyboard shortcuts

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