logger

package
v0.0.0-...-431d825 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

INSTRUCTION:

Put the following code in initialize()

logid := GetNextLogID()
StartLogger(logid)

It is possible to add user defined regions for trace by adding:

defer trace.StartRegion(context.Background(), regionName).End()

For example, in order to add it to every handler of http, one can write a wrapper as follows:

handleFunc := func(p goji.Pattern, h func(http.ResponseWriter, *http.Request)) {
	regionName := GetFunctionName(h)
	mux.HandleFunc(p, func(a http.ResponseWriter, b *http.Request) {
		defer trace.StartRegion(context.Background(), regionName).End()
		h(a, b)
	})
}

If you are using echo, the following code works:

func TraceMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
	return func(c echo.Context) error {
		defer trace.StartRegion(c.Request().Context(), c.Request().Method + " " + c.Path()).End()
		return next(c)
	}
}
func main() {
	e := echo.New()
	// ...
	e.Use(TraceMiddleware)
}

Index

Constants

This section is empty.

Variables

View Source
var LogFilePath = "/tmp/isucon/"
View Source
var LoggerBashScript = "/usr/bin/logger.sh"
View Source
var UseTrace = false

Functions

func AlpMiddleware

func AlpMiddleware(next echo.HandlerFunc) echo.HandlerFunc

func ExecuteCommand

func ExecuteCommand(bashscript string) (string, error)

func GetFunctionName

func GetFunctionName(i interface{}) string

func GetNextLogID

func GetNextLogID() string

func MustExecuteCommand

func MustExecuteCommand(bashscript string) string

func StartLogger

func StartLogger(id string, BenchmarkTime int)

Types

type AlpTrace

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

func New

func New() *AlpTrace

New creates AlpTrace

func (*AlpTrace) Start

func (c *AlpTrace) Start() *AlpTraceRegion

type AlpTraceRegion

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

func (*AlpTraceRegion) Stop

func (r *AlpTraceRegion) Stop(method string, uri string, status int, body_bytes int64)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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