logrushooksentry

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: Apache-2.0 Imports: 6 Imported by: 8

README

installation

go get github.com/maksim-paskal/logrus-hook-sentry

envieronment

export SENTRY_DSN=https://123@sentry.com/345

usage

package main

import (
	"errors"

	logrushooksentry "github.com/maksim-paskal/logrus-hook-sentry"
	log "github.com/sirupsen/logrus"
)

var ErrTest error = errors.New("test error")

func main() {
	hook, err := logrushooksentry.NewHook(logrushooksentry.Options{
		Release: "test",
	})
	if err != nil {
		log.WithError(err).Fatal()
	}

	log.AddHook(hook)

	log.Info("test info")
	log.Warn(ErrTest)
	log.WithError(ErrTest).Error("some message")

	defer hook.Stop()
}

Documentation

Overview

Copyright paskal.maksim@gmail.com Licensed under the Apache License, Version 2.0 (the "License") you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

View Source
const (
	RequestURL        = "requestURL"
	RequestMethod     = "requestMethod"
	RequestRemoteAddr = "requestRemoteAddr"
	RequestRequestURI = "requestRequestURI"
	RequestHost       = "requestHost"
)

Variables

This section is empty.

Functions

func AddRequest added in v0.0.8

func AddRequest(req *http.Request) log.Fields

Types

type Hook

type Hook struct {
	// contains filtered or unexported fields
}

func NewHook

func NewHook(ctx context.Context, options Options) (*Hook, error)

create new Hook.

func (*Hook) Fire

func (hook *Hook) Fire(entry *log.Entry) error

func to interface log.Hook.Fire.

func (*Hook) Levels

func (hook *Hook) Levels() []log.Level

func to interface log.Hook.Levels.

type Options

type Options struct {
	SentryDSN     string
	Environment   string
	Release       string
	LogLevels     []log.Level
	Tags          map[string]string
	FlushDuration time.Duration
	Debug         bool
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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