prettylogs

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 6 Imported by: 0

README

Go Prettylogs

Golang structured logging library

Usage

Get the go-prettylogs library
$ go get github.com/ashokhirpara1/golang-prettylogs
package main

import (
    prettylogs "github.com/ashokhirpara1/golang-prettylogs"
)

func main() {
    prettylogs.Info("main function to boot up everything")
}
Expected output
{"level":"info","method":"main","msg":"main function to boot up everything","time":"2022-09-23T22:59:01+05:30"}
Measure function's execution time in logs
func functionName() {
    defer prettylogs.Exit(prettylogs.Enter())
}

Documentation

Overview

Package prettylogs uses concept of structured logging and the methods to default add structure to log entry payload fields.

The prettylogs package can be used to log entries that use the jsonPayload field to add structure to their payloads. By default it logs "level", "method", "msg", "time" json fields.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enter added in v0.1.1

func Enter() (time.Time, string)

Enter logs the start time of the method

func Error added in v0.1.1

func Error(msg string, errr error)

Error accepts the string message and error It logs the error level message with method name and timestamp

func Exit added in v0.1.1

func Exit(start time.Time, name string)

Exit mesures the execution time of the method

func Fatal added in v0.1.1

func Fatal(method string, msg string, errr error)

Fatal accepts the method name, string message and error It logs the message and exits the program

func Info added in v0.1.1

func Info(str string)

Info accepts the string message It logs the info level message with method name and timestamp

Types

This section is empty.

Directories

Path Synopsis
mock
Package mocklogger is a generated GoMock package.
Package mocklogger is a generated GoMock package.

Jump to

Keyboard shortcuts

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