twirpzap

package module
v0.0.0-...-40a689d Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

GoDoc

twirp zap logger

Logger for twirp servers using zap

Usage

Install locally: go get -u github.com/bakins/twirpzap

Create server hooks:

import (
    "github.com/twitchtv/twirp/example"
    "go.uber.org/zap"
    "github.com/bakins/twirpzap"
)

func main() {
    logger, _ := zap.NewProduction()
    defer logger.Sync() 

    server := example.NewHaberdasherServer(&testHaberdasher{}, twirpzap.ServerHooks(logger))	
}

Log lines will look like:

{"level":"info","ts":1557966347.879602,"caller":"twirp-zap-logger/logger.go:62","msg":"response sent","twirp.package":"twitch.twirp.example","twirp.service":"Haberdasher","twirp.method":"MakeHat","twirp.status":"200","duration":0.000169998}

See also ./example/server.go

LICENSE

See LICENSE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFields

func AddFields(ctx context.Context, fields ...zapcore.Field)

AddFields adds zap fields to the logger.

func FromContext

func FromContext(ctx context.Context) *zap.Logger

FromContext returns the request scoped logger.

func ServerHooks

func ServerHooks(logger *zap.Logger) *twirp.ServerHooks

ServerHooks creates twirp server hooks for logging using zap

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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