echozap

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

README

Quality Gate Status Build status

echo zap

Middleware for Golang Echo framework that provides integration with Uber´s Zap logging library for logging HTTP requests

Usage

package main

import (
	"net/http"

	"github.com/theopenlane/echozap"
	"github.com/labstack/echo/v4"
	"go.uber.org/zap"
)

func main() {
	e := echo.New()

	zapLogger, _ := zap.NewProduction()

	e.Use(echozap.ZapLogger(zapLogger))

	e.GET("/", func(c echo.Context) error {
		return c.String(http.StatusOK, "Hello, World!")
	})
	e.Logger.Fatal(e.Start(":1323"))
}

Logged details

The following information is logged:

  • Status Code
  • Time
  • URI
  • Method
  • Hostname
  • Remote IP Address

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ZapLogger

func ZapLogger(log *zap.Logger) echo.MiddlewareFunc

ZapLogger is a middleware and zap to provide an "access log" like logging for each request.

Types

This section is empty.

Jump to

Keyboard shortcuts

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