httplogger

package
v0.0.0-...-c9bc43d Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 9 Imported by: 1

README

github.com/kjk/common/loghttplogs http requests using siser to a file that rotates every hour (using filerate).

Optionally it can upload those hourly logs, compressed with brotli, to s3-compatible storage.

Then you can write code to analyze the logs.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRequestIPAddress

func GetRequestIPAddress(r *http.Request) string

GetRequestIPAddress returns ip address of the client making the request, taking into account http proxies

func RemotePathFromFilePath

func RemotePathFromFilePath(app, path string) string

<dir>/httplog-2021-10-06_01.txt.br => apps/cheatsheet/httplog/2021/10-06/2021-10-06_01.txt.br return "" if <path> is in unexpected format

func WriteToRecord

func WriteToRecord(rec *siser.Record, r *http.Request, code int, size int64, dur time.Duration)

WriteToRecord can be used outside of Logger

Types

type File

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

func New

func New(dir string, didRotateFn func(path string)) (*File, error)

func (*File) Close

func (l *File) Close() error

func (*File) LogReq

func (l *File) LogReq(r *http.Request, code int, size int64, dur time.Duration) error

Jump to

Keyboard shortcuts

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