logger

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2020 License: MIT Imports: 7 Imported by: 164

README

logger

Code coverage Build Status Go Doc

Simplistic, opinionated logging for Golang

  • Zero dependencies
  • Global logger (with optional local logger)
  • Leveled
  • Useful defaults / i.e. zero-config
  • Simple API
  • Colors on Linux (Windows colors are horrible and unnessecary)
  • Set leveling via environmental variables LOGGER=trace|debug|info|warn|error
[trace] 20:04:57.670116 logger.go:125: trace shows granular timestamp and line info
[debug] 20:04:57 logger.go:129: debug shows regular timestamp and line info
[info]  2019/05/08 20:04:57 info shows timestamp
[warn]  2019/05/08 20:04:57 warn shows timestamp
[error] 2019/05/08 20:04:57 logger.go:141: error shows timestamp and line info

Install

go get github.com/schollz/logger

Usage

package main

import (
	log "github.com/schollz/logger"
)

func main() {
	log.SetLevel("debug")
	log.Debug("hello, world")
}

Contributing

Pull requests are welcome. Feel free to...

  • Revise documentation
  • Add new features
  • Fix bugs
  • Suggest improvements

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(v ...interface{})

func Debugf

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

func Error

func Error(v ...interface{})

func Errorf

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

func GetLevel added in v1.2.0

func GetLevel() (s string)

func Info

func Info(v ...interface{})

func Infof

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

func SetLevel

func SetLevel(s string)

func SetOutput

func SetOutput(w io.Writer)

func Trace

func Trace(v ...interface{})

func Tracef

func Tracef(format string, v ...interface{})

func Warn

func Warn(v ...interface{})

func Warnf

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

Types

type Logger

type Logger struct {
	T, D, I, W, E *log.Logger
	// contains filtered or unexported fields
}

func New

func New() (l *Logger)

func (*Logger) Debugf

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

func (*Logger) Errorf

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

func (*Logger) GetLevel added in v1.1.0

func (l *Logger) GetLevel() (s string)

func (*Logger) Infof

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

func (*Logger) SetLevel

func (l *Logger) SetLevel(s string)

func (*Logger) SetOutput

func (l *Logger) SetOutput(w io.Writer)

func (*Logger) Tracef

func (l *Logger) Tracef(format string, v ...interface{})

func (*Logger) Warnf

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

Jump to

Keyboard shortcuts

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