log

package module
v0.0.0-...-d2fe137 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

README

log

Log package for go.

Nicely color-format-coded in development (when a TTY is attached, otherwise just plain text):

Colored

Example
package main

import (
  "errors"

  "github.com/yunionio/log"
)

func main() {
  log.Debugf("Debug msg")
  log.Infof("Info msg")
  log.Warningf("Warning msg")
  err := errors.New("Unknown error")
  log.Errorf("Error msg: %v", err)
}

Documentation

Overview

Just logrus wrapper, maybe replace in the future

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHookFormatter

func AddHookFormatter(logger *logrus.Logger)

func Debugf

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

func Errorf

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

func Errorln

func Errorln(args ...interface{})

func Fatalf

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

func Infof

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

func Logger

func Logger() *logrus.Logger

func Printf

func Printf(format string, args ...interface{})

func SetLogLevel

func SetLogLevel(logger *logrus.Logger, level logrus.Level)

func SetLogLevelByString

func SetLogLevelByString(logger *logrus.Logger, lvl string) error

func SetVerboseLevel

func SetVerboseLevel(level int32)

func Warningf

func Warningf(format string, args ...interface{})

Types

type TextFormatter

type TextFormatter struct {
	// Set to true to bypass checking for a TTY before outputting colors
	ForceColors bool

	// Force disabling colors
	DisableColors bool

	// Disable timestamp logging, useful when output is redirected to logging
	// system that already adds timestamps
	DisableTimestamp bool

	// Enable logging of just the time passed since beginning of execution.
	ShortTimestamp bool

	// Timestamp format to use for display when a full timestamp is printed.
	TimestampFormat string

	// The fields are sorted by default for a consistent output. For applications
	// that log extremely frequently and don't use the JSON formatter this may not
	// be desired.
	DisableSorting bool

	// Pad msg field with spaces on the right for display.
	// The value for this parameter will be the size of padding.
	// Its default value is zero, which means no padding will be applied for msg.
	SpacePadding int
}

func (*TextFormatter) Format

func (f *TextFormatter) Format(entry *logrus.Entry) ([]byte, error)

type Verbose

type Verbose bool

Verbose is a boolean type that implements Infof (like Printf) etc.

func V

func V(level int32) 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 Infof, and Printf etc. These methods will write to the Info log if called. Thus, one may write either

if log.V(2) { log.Infof("log this") }

or

log.V(2).Infof("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 --log-level flags; both are off by default. If the level in the call to V is at least the value of --log-level for the source file containing the call, the V call will log.

func (Verbose) Debugf

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

func (Verbose) Infof

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

func (Verbose) Printf

func (v Verbose) Printf(format string, args ...interface{})

func (Verbose) Warningf

func (v Verbose) Warningf(format string, args ...interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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