flog

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

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

Go to latest
Published: Sep 8, 2020 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

flog

flog is a minimal, formatted, pretty logging package for Go.

It's optimized for human readability.

slog is recommended for more robust logging.

GoDoc

Install

go get go.coder.com/flog

Usage

flog.Info("hello %.3f", 1/3.0)
flog.Success("finished that")
flog.Error("oops")

log := flog.New().WithPrefix("user %v: ", 500)

log.Error("didn't work out")

produces

example

Documentation

Overview

Package flog provides human-optimized, formatted logging.

Index

Constants

This section is empty.

Variables

View Source
var (
	INFO    = Level(color.HiBlueString("INFO"))
	SUCCESS = Level(color.HiGreenString("SUCCESS"))
	ERROR   = Level(color.RedString("ERROR"))
	FATAL   = Level(color.RedString("FATAL"))
)

Functions

func Error

func Error(msg string, args ...interface{})

func Fatal

func Fatal(msg string, args ...interface{})

func Info

func Info(msg string, args ...interface{})

func Log

func Log(l Level, m string, args ...interface{})

Log logs a message with the default logger.

func Success

func Success(msg string, args ...interface{})

Types

type Level

type Level string

type Logger

type Logger struct {
	W      io.Writer
	Prefix string
}

func New

func New() *Logger

New returns a new logger.

func (*Logger) Error

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

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, args ...interface{})

func (*Logger) Info

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

func (*Logger) Log

func (l *Logger) Log(lvl Level, msg string, args ...interface{})

func (*Logger) Success

func (l *Logger) Success(msg string, args ...interface{})

func (*Logger) WithPrefix

func (l *Logger) WithPrefix(p string, args ...interface{}) *Logger

Jump to

Keyboard shortcuts

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