README

Generic leveled logger interface

Build Status Coverage Status Go.Dev reference Go Report Card Release Downloads

Usage

Checkout example for details.

go get -u clevergo.tech/log
Standard Logger

StdLogger wraps Go standard logger log.Logger.

import (
    stdlog "log"

    "clevergo.tech/log"
)

var logger log.Logger = log.New(os.Stderr, "", stdlog.LstdFlags)
Logrus
import (
    "clevergo.tech/log"
    "github.com/sirupsen/logrus"
)

var logger log.Logger = logrus.New()
Zap
import (
    "clevergo.tech/log"
    "go.uber.org/zap"
)

var logger log.Logger = zap.NewExample().Sugar()
Interface
logger.Debug(args ...interface{})
logger.Debugf(format string, args ...interface{})
logger.Info(args ...interface{})
logger.Infof(format string, args ...interface{})
logger.Warn(args ...interface{})
logger.Warnf(format string, args ...interface{})
logger.Error(args ...interface{})
logger.Errorf(format string, args ...interface{})
logger.Fatal(args ...interface{})
logger.Fatalf(format string, args ...interface{})
Expand ▾ Collapse ▴

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})

	Warn(args ...interface{})
	Warnf(format string, args ...interface{})

	Error(args ...interface{})
	Errorf(format string, args ...interface{})

	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
}

    Logger is a general logger interface.

    type StdLogger

    type StdLogger struct {
    	*log.Logger
    }

      StdLogger is a wrapper of standard logger.

      func New

      func New(out io.Writer, prefix string, flag int) *StdLogger

        New returns a standard logger.

        func (*StdLogger) Debug

        func (l *StdLogger) Debug(args ...interface{})

          Debug implements Logger's Debug.

          func (*StdLogger) Debugf

          func (l *StdLogger) Debugf(format string, args ...interface{})

            Debugf implements Logger's Debugf.

            func (*StdLogger) Error

            func (l *StdLogger) Error(args ...interface{})

              Error implements Logger's Error.

              func (*StdLogger) Errorf

              func (l *StdLogger) Errorf(format string, args ...interface{})

                Errorf implements Logger's Errorf.

                func (*StdLogger) Fatal

                func (l *StdLogger) Fatal(args ...interface{})

                  Fatal implements Logger's Fatal.

                  func (*StdLogger) Fatalf

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

                    Fatalf implements Logger's Fatalf.

                    func (*StdLogger) Info

                    func (l *StdLogger) Info(args ...interface{})

                      Info implements Logger's Info.

                      func (*StdLogger) Infof

                      func (l *StdLogger) Infof(format string, args ...interface{})

                        Infof implements Logger's Infof.

                        func (*StdLogger) Warn

                        func (l *StdLogger) Warn(args ...interface{})

                          Warn implements Logger's Warn.

                          func (*StdLogger) Warnf

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

                            Warnf implements Logger's Warnf.

                            Source Files