logging

package
v2.26.3 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2024 License: MIT Imports: 4 Imported by: 0

README

Logging - Hyperf jet middleware

logging middleware for Hyperf jet.

Usage Example

package main

import (
	"context"

	"github.com/go-kratos/kratos/v2/log"

	"github.com/go-kratos-ecosystem/components/v2/hyperf/jet"
	"github.com/go-kratos-ecosystem/components/v2/hyperf/jet/middleware/logging"
)

func main() {
	client, err := jet.NewClient(
		jet.WithTransporter(nil),
		jet.WithService("Example/User/MoneyService"),
	)
	if err != nil {
		panic(err)
	}

	// base usage
	client.Use(logging.New()) // use github.com/go-kratos/kratos/v2/log.DefaultLogger

	// with options
	client.Use(logging.New(
		logging.Logger(&customLogger{}),
	))

	// call service
	client.Invoke(context.Background(), "service", []any{"..."}, nil)
}

type customLogger struct{}

var _ log.Logger = (*customLogger)(nil)

func (c *customLogger) Log(level log.Level, keyvals ...any) error {
	// custom log
	return nil
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) jet.Middleware

Types

type Option

type Option func(*options)

func Logger

func Logger(logger log.Logger) Option

Jump to

Keyboard shortcuts

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