humanize15

package module
v0.0.0-...-7e434bb Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2016 License: MIT Imports: 4 Imported by: 0

README

go-humanize15 Build Status GoDoc

log15.Handler that humanize the supported context keys to human readable strings

Installation

The recommended way to install go-humanize15

go get -u github.com/mcuadros/go-humanize15

Examples

import (
    "os"

    "github.com/mcuadros/go-humanize15"
    "gopkg.in/inconshreveable/log15.v2"
)

func main() {
    log := log15.New()
    log.SetHandler(humanize15.HumanizeHandler(
        log15.StreamHandler(os.Stdout, log15.LogfmtFormat())
    ))

    log.Warn("foo", "rate", 1024, "elapsed", 1024)
}

//t=2016-02-08T00:13:32+0100 lvl=warn msg=foo rate="1.0 kB/s" elapsed="1.024µs"

License

MIT, see LICENSE

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Supported = map[Keyword]Kind{
	"rate": Rate, "speed": Rate,
	"size": Size, "bytes": Size,
	"duration": Duration, "time": Duration, "elapsed": Duration,
}

Supported defines how they keywords are translated

Functions

func HumanizeHandler

func HumanizeHandler(h log15.Handler) log15.Handler

HumanizeHandler returns a log15.Handler that humanize the supported context keys to human readable strings

Types

type Keyword

type Keyword string

Keyword defines the keywords where look for humanizable kinds

type Kind

type Kind int

Kind defines the supported humanizables kinds

const (
	// Rate any number is translete to a string like [x]kb/s
	Rate Kind = iota
	// Size any number is translated to a string like [x]kb
	Size
	// Duration any number is translated to a time.Duration
	Duration
)

Jump to

Keyboard shortcuts

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