ginlogr

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package ginlogr provides log handling using logr package. Code structure based on ginrus package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ginlogr

func Ginlogr(logger logr.Logger, timeFormat string, utc bool) gin.HandlerFunc

Ginlogr returns a gin.HandlerFunc (middleware) that logs requests using github.com/go-logr/logr.

Requests with errors are logged using logr.Error(). Requests without errors are logged using logr.Info().

It receives:

  1. A time package format string (e.g. time.RFC3339).
  2. A boolean stating whether to use UTC time zone or local.

func RecoveryWithLogr

func RecoveryWithLogr(logger logr.Logger, timeFormat string, utc, stack bool) gin.HandlerFunc

RecoveryWithLogr returns a gin.HandlerFunc (middleware) that recovers from any panics and logs requests using uber-go/logr. All errors are logged using logr.Error(). stack means whether output the stack info. The stack info is easy to find where the error occurs but the stack info is too large.

Types

This section is empty.

Jump to

Keyboard shortcuts

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