log

package module
v0.0.0-...-5cc2ac0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 5 Imported by: 1

README

log

GetStdTextLogger

Returns an instantiated https://github.com/rs/zerolog object.

import "github.com/northwood-labs/golang-utils/log"

func main() {
    logger := log.GetStdTextLogger()
    log.Info().Str("foo", "bar").Msg("Hello World")

    // Output: 2006-01-02T15:04:05Z07:00 | INFO  | Hello World foo=bar
}

GetStdJSONLogger

Returns an instantiated https://github.com/rs/zerolog object.

import "github.com/northwood-labs/golang-utils/log"

func main() {
    logger := log.GetStdJSONLogger()

    err := errors.New("A repo man spends his life getting into tense situations")
    service := "myservice"

    log.Fatal().
        Err(err).
        Str("service", service).
        Msgf("Cannot start %s", service)

    // Output: {"time":1516133263,"level":"fatal","error":"A repo man spends his life getting into tense situations","service":"myservice","message":"Cannot start myservice"}
    //         exit status 1
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStdJSONLogger

func GetStdJSONLogger() zerolog.Logger

GetStdJSONLogger is a standard plain-text logger.

func GetStdTextLogger

func GetStdTextLogger() zerolog.Logger

GetStdTextLogger is a standard plain-text logger.

Types

This section is empty.

Jump to

Keyboard shortcuts

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