logger

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 6 Imported by: 0

README

go-kiss-logger

A super awesome logger that aims to keep it simple, stupid!

How to use it?

In your go.mod file add:

require (
        github.com/asharif/go-kiss-logger v1.0.0
)

In your code add:

import (
        log "github.com/asharif/go-kiss-logger"
)

...

//examples
logger := log.GetInstance()
logger.Info("This is an INFO level log")
logger.Warn("This is an WARN level log")
logger.Error("This is an ERROR level log")
logger.Fatal("This is an FATAL level log. It will exit with the provided code", 1)

Output will look like:

2020-12-02T09:05:48.789Z | INFO  | ...sers/asharif/development/go-kiss-logger/main.go:10 | This is an INFO level log
2020-12-02T09:05:48.789Z | WARN  | ...sers/asharif/development/go-kiss-logger/main.go:11 | This is an WARN level log
2020-12-02T09:05:48.789Z | ERROR | ...sers/asharif/development/go-kiss-logger/main.go:12 | This is an ERROR level log
main.main()
        /Users/asharif/development/go-kiss-logger/main.go:12 +0x8f
2020-12-02T09:05:48.789Z | FATAL | ...sers/asharif/development/go-kiss-logger/main.go:13 | This is an FATAL level log. It will exit with the provided code
main.main()
        /Users/asharif/development/go-kiss-logger/main.go:13 +0xbb
exit status 1

Note that INFO and WARN will write to the stdout, ERROR and FATAL will write to the stderr.

How to bump version numbers

See the .github/workflows/main.yaml. Specifically the following section:

default_bump: major #values major, minor, patch. default is patch

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxInt32

func MaxInt32(a, b int) int

MaxInt32 returns the max of two int32

func MaxInt64

func MaxInt64(a, b int64) int64

MaxInt64 returns the max of two int64

Types

type Logger

type Logger struct {
}

Logger helps us with logging

func GetInstance

func GetInstance() *Logger

GetInstance returns a threadsafe singleton of the logger

func (*Logger) Debug added in v1.1.0

func (l *Logger) Debug(msg string)

Debug logs at the warn level to the stdout

func (*Logger) Error

func (l *Logger) Error(msg string)

Error logs at the error level to the stderr as well as a stack trace.

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, exitCode int)

Fatal logs at the fatal level to the stderr as well as a stack trace along with exiting the process with the given exitCode

func (*Logger) Info

func (l *Logger) Info(msg string)

Info logs at the info level to the stdout

func (*Logger) TurnOffLogs

func (l *Logger) TurnOffLogs()

TurnOffLogs turns off all logging for the purpose of running tests

func (*Logger) Warn

func (l *Logger) Warn(msg string)

Warn logs at the warn level to the stdout

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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