logp

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Configure

func Configure(cfg Config) error

func ConfigureWithOutputs

func ConfigureWithOutputs(cfg Config, outputs ...zapcore.Core) error

func ConsoleEncoderConfig

func ConsoleEncoderConfig() zapcore.EncoderConfig

func JSONEncoderConfig

func JSONEncoderConfig() zapcore.EncoderConfig

func Sync

func Sync() error

Sync flushes any buffered log entries. Applications should take care to call Sync before exiting.

Types

type Config

type Config struct {
	Consumer  string
	JSON      bool     `config:"json"`
	Level     Level    `config:"level"`
	Selectors []string `config:"selectors"`

	ToStderr bool `config:"to_stderr"`
	ToFiles  bool `config:"to_files"`
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig(environment Environment) Config

type Environment

type Environment int

Environment indicates the environment the logger is supped to be run in. The default logger configuration may be different for different environments.

const (
	// DefaultEnvironment is used if the environment the process runs in is not known.
	DefaultEnvironment Environment = iota

	// SystemdEnvironment indicates that the process is started and managed by systemd.
	SystemdEnvironment

	// ContainerEnvironment indicates that the process is running within a container (docker, k8s, rkt, ...).
	ContainerEnvironment

	// MacOSServiceEnvironment indicates that the process is running as a daemon on macOS (e.g. managed via launchctl).
	MacOSServiceEnvironment

	// WindowsServiceEnvironment indicates the the process is run as a windows service.
	WindowsServiceEnvironment

	// InvalidEnvironment indicates that the environment name given is unknown or invalid.
	InvalidEnvironment
)

func ParseEnvironment

func ParseEnvironment(in string) Environment

ParseEnvironment returns the environment type by name. The parse is case insensitive. InvalidEnvironment is returned if the environment type is unknown.

func (Environment) String

func (v Environment) String() string

String returns the string representation the configured environment

func (Environment) Type added in v0.14.0

func (v Environment) Type() string

type Level

type Level int8
const (
	DebugLevel Level = iota - 1
	InfoLevel
	WarnLevel
	ErrorLevel
	CriticalLevel
)

func (Level) Enabled

func (l Level) Enabled(level Level) bool

Enabled returns true if given level is enabled.

func (Level) String

func (l Level) String() string

String returns the name of the logging level

func (Level) ZapLevel

func (l Level) ZapLevel() zapcore.Level

ZapLevel returns zap alternative to logp.Level

type LogOption

type LogOption = zap.Option

LogOption configures a Logger

type Logger

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

Logger logs messages to the configured output.

func L

func L() *Logger

func NewLogger

func NewLogger(selector string, options ...LogOption) *Logger

func (*Logger) Debug

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

Sprint

func (*Logger) Debugf

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

Debugf uses fmt.Sprintf to log a template message.

func (*Logger) Error

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

func (*Logger) Errorf

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

Errorf uses fmt.Sprintf to log a templated message.

func (*Logger) Info

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

func (*Logger) Infof

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

Infof uses fmt.Sprintf to log a templated message.

func (*Logger) Named

func (l *Logger) Named(name string) *Logger

func (*Logger) Sync

func (l *Logger) Sync() error

Sync syncs the logger

func (*Logger) With

func (l *Logger) With(args ...interface{}) *Logger

func (*Logger) WithOptions

func (l *Logger) WithOptions(options ...LogOption) *Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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