internal

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound              = NewHttpError(http.StatusNotFound, "user not found")
	ErrUrlUsernameNotMatchHeader = NewHttpError(http.StatusUnprocessableEntity, "the URL username did not match the Authorization header username")
)
View Source
var (
	Logger = New()
)

Functions

func AbortWithError

func AbortWithError(c *gin.Context, err error)

func ErrorHandleMiddleware

func ErrorHandleMiddleware() gin.HandlerFunc

func LogJson

func LogJson(level LogLevel, jsonMap map[string]interface{})

Types

type HttpError

type HttpError struct {
	StatusCode int
	Message    string
	Hidden     bool
	RelatedErr error
}

func NewBadRequestError

func NewBadRequestError(message string) HttpError

func NewBadRequestErrorFromError

func NewBadRequestErrorFromError(err error) HttpError

func NewHiddenHttpError

func NewHiddenHttpError(statusCode int, message string) HttpError

func NewHiddenHttpErrorWithRelatedError

func NewHiddenHttpErrorWithRelatedError(statusCode int, message string, err error) HttpError

func NewHttpError

func NewHttpError(statusCode int, message string) HttpError

func NewHttpErrorWithRelatedError

func NewHttpErrorWithRelatedError(statusCode int, message string, err error) HttpError

func NewInternalServerError

func NewInternalServerError(err error) HttpError

func (HttpError) Error

func (e HttpError) Error() string

type Log

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

func New

func New() *Log

func NewUsingBuffer

func NewUsingBuffer(buffer *bufio.Writer) *Log

Create a new logger using a buffer, such as to a file

func (*Log) Error

func (l *Log) Error(_ context.Context, msg string, data ...interface{})

func (*Log) Fatal

func (l *Log) Fatal(v ...interface{})

func (*Log) Fatalf

func (l *Log) Fatalf(format string, args ...interface{})

func (*Log) Fatalln

func (l *Log) Fatalln(message string)

func (*Log) Info

func (l *Log) Info(_ context.Context, msg string, data ...interface{})

func (*Log) LogMode

func (l *Log) LogMode(level logger.LogLevel) logger.Interface

func (*Log) Print

func (l *Log) Print(v ...interface{})

func (*Log) Printf

func (l *Log) Printf(format string, args ...interface{})

func (*Log) Println

func (l *Log) Println(message string)

func (*Log) Trace

func (l *Log) Trace(_ context.Context, begin time.Time, fc func() (string, int64), err error)

Trace print sql message

func (*Log) Warn

func (l *Log) Warn(_ context.Context, msg string, data ...interface{})

func (*Log) Warnf

func (l *Log) Warnf(format string, args ...interface{})

func (*Log) Warnln

func (l *Log) Warnln(message string)

type LogLevel

type LogLevel int
const (
	Silent LogLevel = iota + 1
	Error
	Warn
	Info
	Fatal
	Panic
)

Jump to

Keyboard shortcuts

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