astilog

package module
v0.0.0-...-12ed50c Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: MIT Imports: 10 Imported by: 12

README

Astilog

Astilog is a wrapper on top of xlog to provide proper configuration

Documentation

Index

Constants

View Source
const (
	FormatJSON = "json"
	FormatText = "text"
)

Formats

View Source
const (
	OutFile   = "file"
	OutStdOut = "stdout"
	OutSyslog = "syslog"
)

Outs

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

func Debugf

func Debugf(format string, v ...interface{})

func Error

func Error(v ...interface{})

func Errorf

func Errorf(format string, v ...interface{})

func Fatal

func Fatal(v ...interface{})

func Fatalf

func Fatalf(format string, v ...interface{})

func Info

func Info(v ...interface{})

func Infof

func Infof(format string, v ...interface{})

func NewXLoggerConfig

func NewXLoggerConfig(c Configuration) (o xlog.Config)

NewXLoggerConfig returns a new xlog.Config

func SetDefaultLogger

func SetDefaultLogger()

SetDefaultLogger sets the default logger

func SetLogger

func SetLogger(l Logger)

SetLogger sets the global logger

func Warn

func Warn(v ...interface{})

func Warnf

func Warnf(format string, v ...interface{})

func WithField

func WithField(k, v string)

func WithFields

func WithFields(fs Fields)

Types

type Configuration

type Configuration struct {
	AppName         string `toml:"app_name"`
	DisableColors   bool   `toml:"disable_colors"`
	Filename        string `toml:"filename"`
	FullTimestamp   bool   `toml:"full_timestamp"`
	Format          string `toml:"format"`
	MessageKey      string `toml:"message_key"`
	Out             string `toml:"out"`
	TimestampFormat string `toml:"timestamp_format"`
	Verbose         bool   `toml:"verbose"`
}

Configuration represents the configuration of the logger

type Fields

type Fields map[string]interface{}

Fields represents logger fields

type Logger

type Logger interface {
	Clone() Logger
	Debug(v ...interface{})
	Debugf(format string, v ...interface{})
	Info(v ...interface{})
	Infof(format string, v ...interface{})
	Warn(v ...interface{})
	Warnf(format string, v ...interface{})
	Error(v ...interface{})
	Errorf(format string, v ...interface{})
	Fatal(v ...interface{})
	Fatalf(format string, v ...interface{})
	WithField(k string, v interface{})
	WithFields(fs Fields)
}

Logger represents a logger

func Clone

func Clone() Logger

Global logger shortcuts

func GetLogger

func GetLogger() Logger

GetLogger returns the global logger

func New

func New(c Configuration) Logger

New creates a new Logger

func NewXLogger

func NewXLogger(c Configuration) Logger

NewXLogger returns a new xlog.Logger

func NopLogger

func NopLogger() Logger

NopLogger returns a nop logger

type LoggerSetter

type LoggerSetter interface {
	SetLogger(l Logger)
}

LoggerSetter represents a logger setter

type Logrus

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

Logrus represents a logrus logger

func (*Logrus) Clone

func (l *Logrus) Clone() Logger

Clone implements the Logger interface

func (*Logrus) Debug

func (l *Logrus) Debug(v ...interface{})

Debug implements the Logger interface

func (*Logrus) Debugf

func (l *Logrus) Debugf(format string, v ...interface{})

Debugf implements the Logger interface

func (*Logrus) Error

func (l *Logrus) Error(v ...interface{})

WithField implements the Logger interface

func (*Logrus) Errorf

func (l *Logrus) Errorf(format string, v ...interface{})

WithField implements the Logger interface

func (*Logrus) Fatal

func (l *Logrus) Fatal(v ...interface{})

WithField implements the Logger interface

func (*Logrus) Fatalf

func (l *Logrus) Fatalf(format string, v ...interface{})

WithField implements the Logger interface

func (*Logrus) Info

func (l *Logrus) Info(v ...interface{})

WithField implements the Logger interface

func (*Logrus) Infof

func (l *Logrus) Infof(format string, v ...interface{})

WithField implements the Logger interface

func (*Logrus) Warn

func (l *Logrus) Warn(v ...interface{})

WithField implements the Logger interface

func (*Logrus) Warnf

func (l *Logrus) Warnf(format string, v ...interface{})

WithField implements the Logger interface

func (*Logrus) WithField

func (l *Logrus) WithField(k string, v interface{})

WithField implements the Logger interface

func (*Logrus) WithFields

func (l *Logrus) WithFields(fs Fields)

WithFields implements the Logger interface

type Writer

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

Writer represents an object capable of writing to the logger

func NewWriter

func NewWriter(fn func(v ...interface{})) *Writer

NewWriter creates a new writer

func (*Writer) Close

func (w *Writer) Close() error

Close closes the writer

func (*Writer) Write

func (w *Writer) Write(i []byte) (n int, err error)

Write implements the io.Writer interface

Jump to

Keyboard shortcuts

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