Browse Source

add deprecated handelers

pull/15/head
andrey 11 months ago
parent
commit
52ae0b3124
  1. 1
      global.go
  2. 2
      handler/logrus/logger.go
  3. 1
      handler/otel/logger.go
  4. 1
      handler/otel/middleware.go
  5. 4
      handler/zap/logger.go
  6. 2
      writer_example_test.go

1
global.go

@ -12,7 +12,6 @@ import (
//nolint:gochecknoglobals,gomnd
var global = With(New(),
WithTime(KeyTime, time.RFC3339),
WithSource(2, TrimPath),
WithLevel(KeyLevel, level.Debug),
WithExit(level.Alert),
WithPanic(level.Emergency),

2
handler/logrus/logger.go

@ -11,11 +11,13 @@ import (
)
// Standard create new standart logrus handler.
// Deprecated: delete after 0.7.0
func Standard() log.Logger {
return New(logrus.StandardLogger())
}
// New create new logrus handler.
// Deprecated: delete after 0.7.0
func New(log *logrus.Logger) log.Logger {
return func(ctx context.Context, data *entry.Entry) (int, error) {
lrgFields := make(logrus.Fields, data.Fields().Len())

1
handler/otel/logger.go

@ -7,6 +7,7 @@ import (
"gitoa.ru/go-4devs/log/entry"
)
// Deprecated: delete after 0.7.0
func New() log.Logger {
return func(ctx context.Context, e *entry.Entry) (int, error) {
addEvent(ctx, e)

1
handler/otel/middleware.go

@ -7,6 +7,7 @@ import (
"gitoa.ru/go-4devs/log/entry"
)
// Deprecated: delete after 0.7.0
func Middleware() log.Middleware {
return func(ctx context.Context, e *entry.Entry, handler log.Logger) (int, error) {
addEvent(ctx, e)

4
handler/zap/logger.go

@ -10,14 +10,17 @@ import (
"go.uber.org/zap"
)
// Deprecated: delete after 0.7.0
func Nop() log.Logger {
return New(zap.NewNop())
}
// Deprecated: delete after 0.7.0
func Example(options ...zap.Option) log.Logger {
return New(zap.NewExample(options...))
}
// Deprecated: delete after 0.7.0
func Production(options ...zap.Option) log.Logger {
z, err := zap.NewProduction(options...)
if err != nil {
@ -27,6 +30,7 @@ func Production(options ...zap.Option) log.Logger {
return New(z)
}
// Deprecated: delete after 0.7.0
func Development(options ...zap.Option) log.Logger {
z, err := zap.NewDevelopment(options...)
if err != nil {

2
writer_example_test.go

@ -22,7 +22,7 @@ func ExampleFormatWithBracket() {
ctx := context.Background()
logger := log.New(log.WithFormat(log.FormatWithBracket()), log.WithStdout()).With(
log.WithSource(10, filepath.Base),
exampleWithTime(log.KeyTime, time.RFC3339), //log.WithTime(log.KeyTime, time.RFC3339),
log.WithLevel(log.KeyLevel, level.Info),
)

Loading…
Cancel
Save