logger

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2019 License: MIT Imports: 4 Imported by: 0

README

FundApps Logger

Combined logger and Sentry handler.

Install

  go get github.com/fundapps/logger

Usage

Example


package main

import (
	"errors"

	"github.com/fundapps/logger"
)

func main() {
	err := errors.New("This is an error")

	logger.Error(logger.WrapErrorWithContext(err, "context error", logger.Fields{"code": 500}))

}

Development Usage

To disable Sentry during Development, use the environment variable APP_ENV

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(err error)

Error logs an error with the error message & converts the message to fields if Fielder is implemented

func Fatal

func Fatal(err error)

Fatal logs errors in the same way as Error then flushes the errors and calls os.Exit(1)

func Flush

func Flush()

Flush blocks until all pending messages have been processed

func Info

func Info(message string, data Fields)

Info logs with the given message & addition fields at the INFO Level This doesn't log to sentry

func Warn

func Warn(message string, data Fields)

Warn logs with the given message & addition fields at the Warn Level

func WarnError

func WarnError(err error)

WarnError logs an error & fields at the Warn Level

func WrapError

func WrapError(inner error, message string) error

WrapError annotates an error with an additional message It also captures the location of the caller

func WrapErrorWithContext

func WrapErrorWithContext(inner error, message string, context Fields) error

WrapErrorWithContext annotates an error with an additional message and contextual fields It also captures the location of the caller

func WrapErrorWithContextAndStack

func WrapErrorWithContextAndStack(inner error, message string, context Fields, stackSkip int) error

WrapErrorWithContextAndStack annotates an error with an additional message and contextual fields It also captures the location of a specific point in the call stack caller -> stackSkip = 0 caller of the caller -> stackSkip = 1 etc...

Types

type Fielder

type Fielder interface {
	ToFields() Fields
}

Fielder is a interface that allows any type to be converted into log fields

type Fields

type Fields map[string]interface{}

Fields is for passing semi-structured data that doesn't already have a type to the logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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