gologging

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 21, 2021 License: Apache-2.0 Imports: 7 Imported by: 17

README

krakend-gologging

An improved logger for the KrakenD framework

How to use it

Import the package

import "github.com/devopsfaith/krakend-gologging"

After parsing the config file (here cfg), call the logger factory with the extra config of the system

logger, _ := logging.NewLogger(cfg.ExtraConfig)

And the logger is ready to be injected

Configuration

Add the github_com/devopsfaith/krakend-gologging section to the service extra config.

Example:

"extra": {
	"github_com/devopsfaith/krakend-gologging": {
		"level":  "INFO",
		"prefix": "[KRAKEND]",
		"syslog": false,
		"stdout": true
	}
}
  1. level: name of the min log level to display
  2. prefix: prefix to use with the application logs
  3. syslog: enable logging over syslog
  4. stdout: enable logging over the stdout

Documentation

Overview

Package gologging provides a logger implementation based on the github.com/op/go-logging pkg

Index

Constants

View Source
const Namespace = "github_com/devopsfaith/krakend-gologging"

Namespace is the key to look for extra configuration details

Variables

View Source
var (
	// ErrEmptyValue is the error returned when there is no config under the namespace
	ErrWrongConfig = fmt.Errorf("getting the extra config for the krakend-gologging module")
	// DefaultPattern is the pattern to use for rendering the logs
	LogstashPattern = `` /* 138-byte string literal not displayed */
	DefaultPattern  = ` %{time:2006/01/02 - 15:04:05.000} %{color}▶ %{level:.6s}%{color:reset} %{message}`
	ActivePattern   = DefaultPattern
)

Functions

func ConfigGetter

func ConfigGetter(e config.ExtraConfig) interface{}

ConfigGetter implements the config.ConfigGetter interface

func NewLogger

func NewLogger(cfg config.ExtraConfig, ws ...io.Writer) (logging.Logger, error)

NewLogger returns a krakend logger wrapping a gologging logger

func SetFormatterSelector

func SetFormatterSelector(f func(io.Writer) string)

SetFormatterSelector sets the ddefaultFormatterSelector function

Types

type Config

type Config struct {
	Level        string
	StdOut       bool
	Syslog       bool
	Prefix       string
	Format       string
	CustomFormat string
}

Config is the custom config struct containing the params for the logger

type Logger

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

Logger is a wrapper over a github.com/op/go-logging logger

func (Logger) Critical

func (l Logger) Critical(v ...interface{})

Critical implements the logger interface

func (Logger) Debug

func (l Logger) Debug(v ...interface{})

Debug implements the logger interface

func (Logger) Error

func (l Logger) Error(v ...interface{})

Error implements the logger interface

func (Logger) Fatal

func (l Logger) Fatal(v ...interface{})

Fatal implements the logger interface

func (Logger) Info

func (l Logger) Info(v ...interface{})

Info implements the logger interface

func (Logger) Warning

func (l Logger) Warning(v ...interface{})

Warning implements the logger interface

Jump to

Keyboard shortcuts

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