logging

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 3 Imported by: 0

README

Logging

Usage

package main

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

	"github.com/go-kratos-ecosystem/components/v2/log/logging"
)

func main() {
	app := kratos.New(
		kratos.Logger(newLogger()),
	)

	if err := app.Run(); err != nil {
		log.Fatal(err)
	}
}

func newLogger() *logging.Logger {
	logger := logging.New(log.DefaultLogger)

	logger.Register("ts", log.With(log.DefaultLogger))

	return logger
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoLogger = errors.New("logging: the logger is not defined")

Functions

This section is empty.

Types

type Logger

type Logger struct {
	log.Logger
	// contains filtered or unexported fields
}

func New

func New(logger log.Logger) *Logger

func (*Logger) Channel

func (l *Logger) Channel(names ...string) log.Logger

func (*Logger) Log

func (l *Logger) Log(level log.Level, keyvals ...interface{}) error

func (*Logger) Register

func (l *Logger) Register(name string, logger log.Logger)

Jump to

Keyboard shortcuts

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