log

package module
v0.0.0-...-83d59e5 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: MIT Imports: 13 Imported by: 66

README

Plog

Godoc Build Status Go Report Card

A pretty logger for Go

Example

package main

import (
	"github.com/unchartedsoftware/plog"
)

func main() {
	// use global log methods
	log.Debug("This is a debug level log")
	log.Info("This", "is", "an", "info", "level", "log")
	log.Warnf("This is a %s level log", "warn")
	log.Error("This is an error level log")

	// only log warnings and errors
	log.SetLevel(log.WarnLevel)

	log.Debug("This is a debug level log, I will be ignored")
	log.Info("This is an info level log, I will be ignored")
	log.Warn("This is a warn level log, you will see me")
	log.Error("This is an error level log, you will see me")

	// create logger instance
	logger := log.NewLogger()
	logger.SetLevel(log.ErrorLevel)
	logger.Debug("This is a debug level log, I will be ignored")
	logger.Info("This is an info level log, I will be ignored")
	logger.Warn("This is a warn level log, I will be ignored")
	logger.Error("This is an error level log, you will see me")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug is for debug level logging events.

func Debugf

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

Debugf is for debug level logging events.

func Error

func Error(args ...interface{})

Error is for unexpected and unrecoverable fatal events.

func Errorf

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

Errorf is for unexpected and unrecoverable fatal events.

func HideGoRoutineID

func HideGoRoutineID()

HideGoRoutineID disables appending the goroutine ID to the log output.

func Info

func Info(args ...interface{})

Info is for high granularity logging events.

func Infof

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

Infof is for high granularity logging events.

func SetLevel

func SetLevel(level Level)

SetLevel sets the current logging output level.

func ShowGoRoutineID

func ShowGoRoutineID()

ShowGoRoutineID enables appending the goroutine ID to the log output.

func Warn

func Warn(args ...interface{})

Warn is for unexpected and recoverable events.

func Warnf

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

Warnf is for unexpected and recoverable events.

Types

type Level

type Level int

Level represents the logging level type enumeration.

const (
	// DebugLevel logging is for high granularity development level logging.
	DebugLevel Level = 1
	// InfoLevel logging is for logging events.
	InfoLevel Level = 2
	// WarnLevel logging is for unexpected and recoverable events.
	WarnLevel Level = 3
	// ErrorLevel logging is for unexpected and unrecoverable fatal events.
	ErrorLevel Level = 4
)

type Logger

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

Logger represents a basic logging struct.

func NewLogger

func NewLogger() *Logger

NewLogger instantiates and returns a new Logger struct.

func (*Logger) Debug

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

Debug is for debug level logging events.

func (*Logger) Debugf

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

Debugf is for debug level logging events.

func (*Logger) Error

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

Error is for unexpected and unrecoverable fatal events.

func (*Logger) Errorf

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

Errorf is for unexpected and unrecoverable fatal events.

func (*Logger) HideGoRoutineID

func (l *Logger) HideGoRoutineID()

HideGoRoutineID disables appending the goroutine ID to the log output.

func (*Logger) Info

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

Info is for high granularity logging events.

func (*Logger) Infof

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

Infof is for high granularity logging events.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

SetLevel sets the current logging output level.

func (*Logger) ShowGoRoutineID

func (l *Logger) ShowGoRoutineID()

ShowGoRoutineID enables appending the goroutine ID to the log output.

func (*Logger) Warn

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

Warn is for unexpected and recoverable events.

func (*Logger) Warnf

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

Warnf is for unexpected and recoverable events.

Jump to

Keyboard shortcuts

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