prettylogger

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 6 Imported by: 0

README

prettylogger

Tests/Linting/Formatting

pretty logger is a minimal, lightweight server logging package. Below is some example output:

server logging output

This package can be installed with go get github.com/idugan100/prettylogger

You can find documentation here.

Documentation

Overview

prettylogger is a minimalistic server logging framework that prints out the request time, duration, http verb, url path, and color coded response code. You start by passing all the places you want to log to that satify the io.Writer interface to the NewPrettyLogger function. Common places might be STDOUT or a log file. This will return a PrettyLogger struct. You can then use the PrettyLoggerMiddleWare function on the struct to wrap any http.Handlerfunc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrettyLogger

type PrettyLogger struct {
	Output io.Writer
}

This struct is the main object of the prettylogger package. You can create one of these yourself with you output locations as writers, or use the NewPrettyLogger function

func NewPrettyLogger

func NewPrettyLogger(writers ...io.Writer) PrettyLogger

Pass all the places you want to log to as writers and this will return a new PrettyLogger struct for you to use

func (PrettyLogger) PrettyLoggerMiddleWare

func (p PrettyLogger) PrettyLoggerMiddleWare(f func(http.ResponseWriter, *http.Request)) http.HandlerFunc

Once you have a PrettyLogger struct, use this function on the struct to wrap http.Handlefunc in order to log all the requests that go though it.

Jump to

Keyboard shortcuts

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