logs

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2020 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 filled logs.Config and use it as common logrus logger instance

package main

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

func main() {
	conf := &logs.Config{
		LogLevel: "warn",
		Debug: true,
		Sentry: &logs.SentryConfig{
			Enable: true,
			DSN: "http://dsn.sentry.com",
		},
	}
	
	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

func GetEnv

func GetEnv(key, fallback string) string

Types

type Config

type Config struct {
	Stage    string
	LogLevel string        `yaml:"level"`
	Debug    bool          `yaml:"debug"`
	Sentry   *SentryConfig `yaml:"sentry"`
}

func (*Config) SetStage

func (c *Config) SetStage()

type Logger

type Logger struct {
	*logrus.Logger
}

func NewLogger

func NewLogger(config *Config) (log *Logger, err error)

NewLogger is logrus instantiating wrapper. Returns configured logrus instance

type SentryConfig

type SentryConfig struct {
	Enable bool   `yaml:"enable"`
	DSN    string `yaml:"dsn"`
}

Jump to

Keyboard shortcuts

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