Back to godoc.org
gomodules.xyz/nats-logr

package natslogr

v0.1.0
Latest Go to latest
Published: Jul 10, 2019 | License: Apache-2.0 | Module: gomodules.xyz/nats-logr

Index

Constants

const (
	Subject     = "cluster_subject"
	ClusterID   = "cluster_id"
	ClientID    = "client_id"
	NatsURL     = "nats_url"
	ConnectWait = "connect_wait"
)

Constants for Nats Streaming Server connection

Variables

var Stats struct {
	Info, Warning, Error OutputStats
}

Stats tracks the number of lines of output and number of bytes per severity level. Values must be read with atomic.LoadInt64.

func Flush

func Flush()

Flush flushes all pending log I/O.

func InitFlags

func InitFlags(flagset *flag.FlagSet)

InitFlags is for explicitly initializing the flags

func NewLogger

func NewLogger(opts Options) logr.Logger

NewLogger returns a logr.Logger which is implemented by nats-logr

type Level

type Level int32

Level specifies a level of verbosity for V logs. *Level implements flag.Value; the -v flag is of type Level and should be modified only through the flag.Value interface.

func (*Level) Get

func (l *Level) Get() interface{}

Get is part of the flag.Value interface.

func (*Level) Set

func (l *Level) Set(value string) error

Set is part of the flag.Value interface.

func (*Level) String

func (l *Level) String() string

String is part of the flag.Value interface.

type Options

type Options struct {
	ClusterID, ClientID, NatsURL, Subject string
}

The Options contains necessary information about nats-connection

type OutputStats

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

OutputStats tracks the number of output lines and bytes written.

func (*OutputStats) Bytes

func (s *OutputStats) Bytes() int64

Bytes returns the number of bytes written.

func (*OutputStats) Lines

func (s *OutputStats) Lines() int64

Lines returns the number of lines written.

type Verbose

type Verbose bool

Verbose is a boolean type that implements Infof (like Printf) etc. See the documentation of V for more information.

func V

func V(level Level) Verbose

V reports whether verbosity at the call site is at least the requested level. The returned value is a boolean of type Verbose, which implements Info, Infoln and Infof. These methods will write to the Info log if called. Thus, one may write either

if natslog.V(2) { natslog.Info("log this") }

or

natslog.V(2).Info("log this")

The second form is shorter but the first is cheaper if logging is off because it does not evaluate its arguments.

Whether an individual call to V generates a log record depends on the setting of the -v and --vmodule flags; both are off by default. If the level in the call to V is at least the value of -v, or of -vmodule for the source file containing the call, the V call will log.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier