slog

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 5 Imported by: 0

README

Slog

Simple Go Slack Logger

Installation

go get -u github.com/hakkasuru/slog

Quick Start

config := slog.NewConfig(
    "<webhook url>",
    "TestExampleLogInfo",
    "<!here>",
)
logger := slog.NewSlackLogger(config)
logger.Info(fmt.Sprintf("API returned http status %d", 500))

demo example

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceGlobalLogger

func ReplaceGlobalLogger(logger *Logger) func()

ReplaceGlobalLogger replaces global logger

Types

type Config

type Config struct {
	WebhookURL   string
	DefaultTitle string
	DefaultTags  []string
}

Config struct for slack configs

func NewConfig

func NewConfig(webhookURL string, defaultTitle string, defaultTags ...string) Config

NewConfig configuration for slack

type Logger

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

Logger struct

func L

func L() *Logger

L global logger

func NewNoopLogger

func NewNoopLogger() *Logger

NewNoopLogger creates no op logger

func NewSlackLogger

func NewSlackLogger(cfg Config) *Logger

NewSlackLogger creates slack logger

func (*Logger) Emergency

func (l *Logger) Emergency(msg string, tags ...string)

Emergency publish log to slack with emergency tag

func (*Logger) Error

func (l *Logger) Error(msg string, tags ...string)

Error publish log to slack with error tag

func (*Logger) Info

func (l *Logger) Info(msg string, tags ...string)

Info publish log to slack with info tag

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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