Skip to content

(Deprecated in hexa)Logurs-kit make logrus tuning very simple by viper and built-in formatter, hooks and output writers.

License

Notifications You must be signed in to change notification settings

Kamva/logrus-kit

Repository files navigation

Deprecated: This package is deprecated in favor of zap and hexa stacked logger.

Logrus-kit is a kit for logrus.

Logrus-kit inspired by Logrus mate

Install

go get github.com/kamva/logrus-kit

Formatter list:

  • json
  • text

Hook list:

  • slack

Output list

  • stdout
  • stderr
  • null

Example

Note: To register default logrus-kit formatters,hooks and outputs , import logrusbase : e.g
import _ "github.com/kamva/logrus-kit/logrusbase"

Example:

package mypackage

import (
	"github.com/kamva/logrus-kit"
	_ "github.com/kamva/logrus-kit/logrusbase"
	"github.com/sirupsen/logrus"
	"github.com/spf13/viper"
)

func main() {
	v := viper.New()
	v.SetDefault("log.level", "info")
	v.SetDefault("log.formatter", "text")
	v.SetDefault("log.output", "stderr")
	v.SetDefault("log.hooks", "")

	logger := logrus.New()

	err := logruskit.Tune(logger, logruskit.NewViperAdapter(v))

	if err != nil {
		panic(err)
	}

	logger.WithFields(logrus.Fields{"test": "is ok"}).Info("salam")
}

Todo:

  • Add more formatter and logger.
  • Write tests.
  • CI.
  • Write example.
  • PR to logrus to add this to other logrus tools.

About

(Deprecated in hexa)Logurs-kit make logrus tuning very simple by viper and built-in formatter, hooks and output writers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages