log

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

README

log

Configuration

  • FileName (String): Name of the log file
    • Default: random name as per lumberjack
  • Compress (Boolean): Compresses old log files with gzip compression
    • Options: false, true
    • Default: false
  • Level (String): Logger Level
    • Options: DEBUG, INFO, WARN, ERROR
    • Default: INFO
  • MaxAge (Int): Number of days to retain old log files
    • Default: - (will not remove any old log files)
  • MaxBackups (Int): Number of old log files to retain
    • Default: - (will retain all old log files)
  • MaxSize (Int): Maximum size of the log file in megabytes
    • Default: 100
  • Encoding (String): Logs will be stored in defined format
    • Options: CONSOLE, JSON
    • Default: CONSOLE

Example

import (
  "github.com/ChaosHQ/common-lib/log"
  "fmt"
)

// load log config and other configs via edict
err := log.Load(cfg)
if err != nil {
  panic(err)
}

log.Log.Info("this will log at INFO level")
log.Log.Infof("this will log at %s level", "INFO")

Documentation

Overview

Package log ...

Index

Constants

This section is empty.

Variables

Log ...

Functions

func Load

func Load(config Config) error

Load ...

Types

type Config

type Config struct {
	FileName   string `json:"FileName" yaml:"FileName"`
	Encoding   string `json:"Encoding" yaml:"Encoding"`
	MaxSize    int    `json:"MaxSize" yaml:"MaxSize"`
	MaxBackups int    `json:"MaxBackups" yaml:"MaxBackups"`
	MaxAge     int    `json:"MaxAge" yaml:"MaxAge"`
	Level      string `json:"Level" yaml:"Level"`
	Compress   bool   `json:"Compress" yaml:"Compress"`
}

Config ...

Jump to

Keyboard shortcuts

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