ginlog

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package ginlog is gin server logger middleware.

Example
package main

import (
	"github.com/boxgo/box/pkg/logger"
	"github.com/boxgo/box/pkg/server/ginserver"
	"github.com/boxgo/box/pkg/server/ginserver/mid/ginlog"
	"github.com/gin-gonic/gin"
)

func main() {
	ginserver.Use(ginlog.Logger())
	ginserver.GET("/ping", func(ctx *gin.Context) {
		ctx.Data(200, "text/plain", []byte("pong"))
	})

	if err := ginserver.Run(); err != nil {
		logger.Fatal(err)
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	Default = StdConfig("default").Build()
)

Functions

func Logger

func Logger() func(ctx *gin.Context)

Types

type Config

type Config struct {
	Skips         []string `config:"skips" desc:"skip urls"`
	UserAgent     bool     `config:"useragent" desc:"log user-agent"`
	RequestIP     bool     `config:"requestIp" desc:"log request ip"`
	RequestHeader bool     `config:"requestHeader" desc:"log request header"`
	RequestQuery  bool     `config:"requestQuery" desc:"log request query"`
	RequestBody   bool     `config:"requestBody" desc:"log request body"`
	ResponseBody  bool     `config:"responseBody" desc:"log response body"`
	// contains filtered or unexported fields
}

Config 配置

func DefaultConfig

func DefaultConfig(key string) *Config

DefaultConfig 默认配置

func StdConfig

func StdConfig(key string, optionFunc ...OptionFunc) *Config

StdConfig 标准配置

func (*Config) Build

func (c *Config) Build() *GinLog

Build 构建实例

func (*Config) Path

func (c *Config) Path() string

Path 实例配置目录

type GinLog

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

func (*GinLog) Logger

func (log *GinLog) Logger() func(ctx *gin.Context)

type OptionFunc

type OptionFunc func(*Config)

OptionFunc 选项信息

Jump to

Keyboard shortcuts

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