mzlog

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2020 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewZapLogger

func NewZapLogger(c *Config) *zap.Logger

NewZapLogger returns a new zap.Logger with the given config.

func Process

func Process(logger *zap.Logger)

Process logs info about the process to the logger.

Types

type Config

type Config struct {
	Level zapcore.Level

	CallerKey     string
	LevelKey      string
	MessageKey    string
	NameKey       string
	TimeKey       string
	StacktraceKey string

	Encoder      EncoderType
	TimeEncoder  TimeEncoderType
	LevelEncoder LevelEncoderType

	EnableStacktrace bool
	EnableCaller     bool

	SampleInitial    int
	SampleThereafter int

	Metrics     *Metrics
	WriteSyncer zapcore.WriteSyncer
}

Config specifies the configuration of a Logger.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default Config.

func (*Config) RegisterCommonFlags

func (c *Config) RegisterCommonFlags(fs *flag.FlagSet) *Config

RegisterCommonFlags registers basic fields of the Config as flags in the FlagSet. If fs is nil, flag.CommandLine is used.

func (*Config) RegisterFlags

func (c *Config) RegisterFlags(fs *flag.FlagSet) *Config

RegisterFlags registers fields of the Config as flags in the FlagSet. If fs is nil, flag.CommandLine is used.

type EncoderType

type EncoderType int

An EncoderType specifies which Encoder to use.

const (
	// JSONType creates a fast, low-allocation JSON encoder.
	JSONType EncoderType = iota

	// ConsoleType creates an encoder whose output is designed for human
	// consumption, rather than machine consumption.
	ConsoleType
)

func (*EncoderType) Get

func (t *EncoderType) Get() interface{}

Get implements the flag.Getter interface.

func (*EncoderType) Set

func (t *EncoderType) Set(s string) error

Set implements the flag.Value interface.

func (*EncoderType) String

func (t *EncoderType) String() string

String implements the flag.Value interface.

type LevelEncoderType

type LevelEncoderType int

A LevelEncoderType specifies which LevelEncoder to use.

const (
	// UppercaseType serializes a Level to an all-caps string. For example,
	// InfoLevel is serialized to "INFO".
	UppercaseType LevelEncoderType = iota

	// LowercaseType serializes a Level to a lowercase string. For example,
	// InfoLevel is serialized to "info".
	LowercaseType

	// ColorType serializes a Level to an all-caps string and adds color.
	// For example, InfoLevel is serialized to "INFO" and colored blue.
	ColorType
)

func (*LevelEncoderType) Get

func (t *LevelEncoderType) Get() interface{}

Get implements the flag.Getter interface.

func (*LevelEncoderType) Set

func (t *LevelEncoderType) Set(s string) error

Set implements the flag.Value interface.

func (*LevelEncoderType) String

func (t *LevelEncoderType) String() string

String implements the flag.Value interface.

type Metrics

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

Metrics are a prometheus.Collector for log metrics.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics returns new Metrics.

func (*Metrics) Collect

func (m *Metrics) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (*Metrics) Describe

func (m *Metrics) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

type TimeEncoderType

type TimeEncoderType int

A TimeEncoderType specifies which TimeEncoder to use.

const (
	// ISO8601Type serializes a time.Time to an ISO8601-formatted string with
	// millisecond precision.
	ISO8601Type TimeEncoderType = iota

	// MillisecondsType serializes a time.Time to a floating-point number of
	// milliseconds since the Unix epoch.
	MillisecondsType

	// NanosecondsType serializes a time.Time to an integer number of nanoseconds
	// since the Unix epoch.
	NanosecondsType

	// SecondsType serializes a time.Time to a floating-point number of seconds
	// since the Unix epoch.
	SecondsType
)

func (*TimeEncoderType) Get

func (t *TimeEncoderType) Get() interface{}

Get implements the flag.Getter interface.

func (*TimeEncoderType) Set

func (t *TimeEncoderType) Set(s string) error

Set implements the flag.Value interface.

func (*TimeEncoderType) String

func (t *TimeEncoderType) String() string

String implements the flag.Value interface.

Jump to

Keyboard shortcuts

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