logs

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: MIT Imports: 4 Imported by: 0

README

logs-go

CircleCI codecov

Logrus wrapper for easy use with sentry hook, database (gorm) and mux (gin) loggers.

Usage

Initiate new logger with prefilled logs.Config and use it as common logrus logger instance

package main

import (
	"time"
	
	"github.com/microparts/logs-go"
)

func main() {
	conf := &logs.Config{
		Level:"warn",
		Format: "text",
		Sentry: &logs.SentryConfig{
			Enable: true,
			Stage:"test",
			DSN: "http://dsn.sentry.com",
			ResponseTimeout: 0,
			StackTrace: logs.StackTraceConfig{
				Enable: true,
			},
		},
	}
	
	l, err := logs.NewLogger(conf)
	if err != nil {
		panic(err)
	}
	
	l.Warn("log some warning")
}

Licence

The software is provided under MIT Licence.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Level  string        `yaml:"level"`
	Format string        `yaml:"format"`
	Sentry *SentryConfig `yaml:"sentry,omitempty"`
}

type Logger added in v1.1.0

type Logger struct {
	*logrus.Logger
}

func NewLogger

func NewLogger(cfg *Config) (*Logger, error)

NewLogger is logrus instantiating wrapper. Returns configured logrus instance

type SentryConfig

type SentryConfig struct {
	Enable          bool             `yaml:"enable"`
	Stage           string           `yaml:"stage"`
	MinlLogLevel    string           `yaml:"min_log_level"`
	DSN             string           `yaml:"dsn"`
	ResponseTimeout time.Duration    `yaml:"response_timeout"`
	StackTrace      StackTraceConfig `yaml:"stacktrace"`
}

type StackTraceConfig

type StackTraceConfig struct {
	Enable  bool `yaml:"enable"`
	Context int  `yaml:"context"`
}

Jump to

Keyboard shortcuts

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