Esempio n. 1
0
File: client.go Progetto: logan/heim
func (c *Client) FromRequest(ctx scope.Context, r *http.Request) {
	c.UserAgent = r.Header.Get("User-Agent")
	c.Connected = time.Now()
	c.IP = getIP(r)

	var k clientKey
	ctx.Set(k, c)
}
Esempio n. 2
0
func SetLogger(ctx scope.Context, logger *logrus.Logger) {
	ctx.Set(loggerKey, logger)
}
Esempio n. 3
0
func LoggingContext(ctx scope.Context, prefix string) scope.Context {
	logger := log.New(os.Stdout, prefix, logFlags)
	ctx.Set(logCtx, logger)
	return ctx
}
Esempio n. 4
0
func LoggingContext(ctx scope.Context, w io.Writer, prefix string) scope.Context {
	logger := log.New(w, prefix, logFlags)
	ctx.Set(logCtx, logger)
	return ctx
}