web

package
v0.0.0-...-c3423aa Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 18 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

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

func Shutdown

func Shutdown()

Shutdown the http server

Types

type AccessLog

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

func (a AccessLog) String() string

type PlainFormatter

type PlainFormatter struct {
	TimestampFormat string
	LevelDesc       []string
}

PlainFormatter is a plain text formatter

func (*PlainFormatter) Format

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

Format formats the log entry

type StructuredLogger

type StructuredLogger struct {
	Logger *logrus.Logger
}

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

func (*StructuredLogger) NewLogEntry

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

NewLogEntry creates a new logrus.Entry from the request

type StructuredLoggerEntry

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

StructuredLoggerEntry is a logrus.Entry with some additional fields

func (*StructuredLoggerEntry) Panic

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

Panic is a convenience method for Logrus

func (*StructuredLoggerEntry) Write

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