flog

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2022 License: MIT Imports: 5 Imported by: 13

README

flog

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

It's optimized for human readability and CLIs.

  • Log levels color-code the timestamp
  • Log level doesn't change the width of the prefix

slog is recommended for robust logging.

GoDoc

Install

go get github.com/coder/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")

Output

example

Documentation

Overview

Package flog provides human-optimized, formatted logging.

Index

Constants

View Source
const (
	ClockFormat     = "15:04:05"
	DateClockFormat = "2006-01-02" + ClockFormat
)

Time formats

Variables

This section is empty.

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 Success

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

Types

type Logger

type Logger struct {
	W          io.Writer
	TimeFormat string
	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) 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