package
1.10.0
Repository: https://github.com/lancer-kit/armory.git
Documentation: pkg.go.dev

# README

GoDoc

log

log is a simple wrapper for logrus.

Usage

To start use the log package add import:

...
import (
  "github.com/lancer-kit/armory/log" // imports as package "log"
)
...
  • Fill config structure:
FieldTypeDescription
AppNamestringidentifier of the app
Levelstringlevel of the logging output
Sentrystringdsn string for the sentry hook
AddTraceboolenable the inclusion of the file name and line number in the log
JSONboolenable json formatted output
  • Call init function:
logger, err := log.Init(config)

A once-initialized logrus.Entry can then be used anywhere. To access it, use the getter:

logger := log.Get()

Example

package main

import (
    "fmt"
    "github.com/lancer-kit/armory/log" // imports as package "log"
)

var config = log.Config{
    AppName: "my-app",
    Level: "warn",
    Sentry: "http://....",
    AddTrace: true,  
}

logger, err := log.Init(config)
if err != nil {
    fmt.Println(err)
    panic("unable to init log Entry")
}

logger.Info("log initialized")
logger.Error("log test error")

logger2 := log.Get()

fmt.Println(logger == logger2) // true