echolog15

package module
v0.0.0-...-48a0a32 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2019 License: MIT Imports: 5 Imported by: 3

README

Log15 middleware for Echo web-framework godoc reference

Example

package main

import (
    "errors"
    "net/http"

    "github.com/labstack/echo"
    "github.com/schmooser/go-echolog15"
    "gopkg.in/inconshreveable/log15.v2"
)

// Handler
func hello(c *echo.Context) error {
    return c.String(http.StatusOK, "Hello, World!\n")
}

func main() {
    // Echo instance
    e := echo.New()

    // logger
    log := log15.New()

    // Logger middleware
    e.Use(echolog15.Logger(log))

    // Set error handler
    e.SetHTTPErrorHandler(echolog15.HTTPErrorHandler(log))

    // Routes
    e.Get("/", hello)

    // Routes
    e.Get("/error", func(c *echo.Context) error {
        err := errors.New("Some test error")
        return err
    })

    // Start server
    e.Run(":1323")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPErrorHandler

func HTTPErrorHandler(l LogProvider) echo.HTTPErrorHandler

HTTPErrorHandler is an error handler with log15 support.

func Logger

Logger is a logger middleware for log15 package.

Types

type LogProvider

type LogProvider interface {
	Debug(msg string, ctx ...interface{})
	Info(msg string, ctx ...interface{})
	Error(msg string, ctx ...interface{})
}

LogProvider provides function required for logging.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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