Skip to content

Latest commit

 

History

History

slog

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Hertz Slog (This is a community driven project)

Introduction

This is a logger library that uses slog to implement the Hertz logger interface

Usage

Download and install it:

go get github.com/hertz-contrib/logger/slog

Import it in your code:

import hertzslog "github.com/hertz-contrib/logger/slog"

Simple Example:

package main

import (
	"context"

	"github.com/cloudwego/hertz/pkg/common/hlog"
	hertzslog "github.com/hertz-contrib/logger/slog"
)

func main() {
	logger := hertzslog.NewLogger()
	hlog.SetLogger(logger)

	...

	hlog.CtxInfof(context.Background(), "hello %s", "hertz")
}