where

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2019 License: BSD-3-Clause Imports: 4 Imported by: 0

README

Runtime package for Kiwi log (experimental)

The package adds runtime information (package name, function, line number) as the keys and the values to the logger context.

import (
  "os"
  
  "github.com/grafov/kiwi"
  "github.com/grafov/kiwi/where"
)

func main() {
	kiwi.SinkTo(os.Stdout, kiwi.AsLogfmt()).Start()

	kiwi.With(where.What(where.File | where.Line | where.Func))
	kiwi.Log("key", "value")
}

The result log record will be like that:

 lineno=11 file="path/to/main.go" function="main.main" key="value"

Documentation

Index

Constants

View Source
const (
	// Names that defines the that parts of runtime information should
	// be passed.
	FilePos  = 1
	Function = 2
)

Variables

This section is empty.

Functions

func What

func What(parts int) []*kiwi.Pair

What adds runtime information to the logger context. Remember that it returns a slice of pairs so add it this way:

log.Add(where.What(where.Filename, where.Func, where.Line)...)

Types

This section is empty.

Jump to

Keyboard shortcuts

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