httplog

package
v0.0.0-...-6076d7e Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const LOG_DEF_FILE_NAME = "./httplog/http.log"

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enable     bool `yaml:"enable" json:"enable"`             // состояние логирования 'true', 'false'
	LogInReq   bool `yaml:"log_in_req" json:"log_in_req"`     // логировать входящие запросы
	LogOutReq  bool `yaml:"log_out_req" json:"log_out_req"`   // логировать исходящие запросы
	LogInResp  bool `yaml:"log_in_resp" json:"log_in_resp"`   // логировать входящие ответы
	LogOutResp bool `yaml:"log_out_resp" json:"log_out_resp"` // логировать исходящие ответы
	LogBody    bool `yaml:"log_body" json:"log_body"`         // логировать тело запроса

	FileConfig *_log.FileConfig `json:"file" yaml:"file"` // конфигурация для логирования в файл, если имя файла пустое, то используется глобальное
}

Config represent аn HTTP logger config

type Logger

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

Logger represent аn HTTP logger

func New

func New(ctx context.Context, cfg *Config) (*Logger, error)

New - создает новый Logger

func (*Logger) GetConfig

func (log *Logger) GetConfig() *Config

GetConfig get logger config

func (*Logger) LogHTTPInRequest

func (log *Logger) LogHTTPInRequest(ctx context.Context, req *http.Request) error

LogHTTPInRequest process HTTP logging for In request

func (*Logger) LogHTTPInResponse

func (log *Logger) LogHTTPInResponse(ctx context.Context, resp *http.Response) error

LogHTTPInResponse process HTTP logging for In response

func (*Logger) LogHTTPOutRequest

func (log *Logger) LogHTTPOutRequest(ctx context.Context, req *http.Request) error

LogHTTPOutRequest process HTTP logging for Out request

func (*Logger) LogHTTPOutResponse

func (log *Logger) LogHTTPOutResponse(ctx context.Context, header map[string]string, responseBuf []byte, status int) error

LogHTTPOutResponse process HTTP logging for Out Response

func (*Logger) SetConfig

func (log *Logger) SetConfig(cfg *Config) error

SetConfig set new logger config

func (*Logger) Shutdown

func (log *Logger) Shutdown() (myerr error)

Shutdown shutting down service

Jump to

Keyboard shortcuts

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