ale

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 3 Imported by: 2

README

Advanced Logging Engine (ALE)

ale-final-min

A simple yet very powerful logging package great for quick projects and scaling your log collection design.

image

How to Install

go get -u github.com/seanmmitchell/ale

How to Use

import (
    "github.com/seanmmitchell/ale"
    "github.com/seanmmitchell/ale/pconsole"
)

func main() {
    le := ale.CreateLogEngine("Example")
    le.AddLogPipeline(ale.Info, pconsole.Log)

    le.Log(ale.Critical, "Critical Log")
    le.Log(ale.Error, "Error Log")
    le.Log(ale.Warning, "Warning Log")
    le.Log(ale.Info, "Info Log")
    le.Log(ale.Verbose, "Verbose Log")
    le.Log(ale.Debug, "Debug Log")

    sle := le.CreateSubEngine("Sub-Engine")
    sle.AddLogPipeline(ale.Warning, pconsole.Log)

    sle.Log(ale.Critical, "Critical Log")
    sle.Log(ale.Error, "Error Log")
    sle.Log(ale.Warning, "Warning Log")
    sle.Log(ale.Info, "Info Log")
    sle.Log(ale.Verbose, "Verbose Log")
    sle.Log(ale.Debug, "Debug Log")
}

image

License

This work is licensed under the MIT License.
Please review LICENSE (LICENSE.md) for specifics.

Documentation

Index

Constants

View Source
const (
	Critical = iota
	Error    = iota
	Warning  = iota
	Info     = iota
	Verbose  = iota
	Debug    = iota
)

Log Types

Variables

This section is empty.

Functions

func TranslateSeverity

func TranslateSeverity(sev int) string

Types

type Log

type Log struct {
	Time     time.Time
	Source   string
	Severity int
	Message  string
}

func (*Log) String added in v1.0.3

func (log *Log) String() string

type LogEngine

type LogEngine struct {
	Name string
	// contains filtered or unexported fields
}

Log Engine

func CreateLogEngine

func CreateLogEngine(name string) *LogEngine

Engine

func (*LogEngine) AddLogPipeline

func (le *LogEngine) AddLogPipeline(sev int, out func(log *Log) error)

func (*LogEngine) CreateSubEngine

func (le *LogEngine) CreateSubEngine(name string) *LogEngine

func (*LogEngine) Log

func (le *LogEngine) Log(sev int, message string)

type LogPipeline

type LogPipeline struct {
	Severity int
	Output   func(log *Log) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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