Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

monstercat/gologx

Repository files navigation

logx

Custom logging solution, and associated server for remote consolidation.

The basic premise is to allow logging not only to std output or local file, but also to a remote host which is queryable by postgres.

For examples, please see HostHandlerTest and GenericHandlerTest

Initialization

A LogHandler is required and is used to handle logging for the system.

It requires a list of handlers. For example:

hostHandler := &logx.HostHandler{
    ...
}

logHandler := &LogHandler{
    Handlers: []Handler{   
        hostHandler,
        logx.StdHandler,
    },   
}

errCh := make(chan error)
go func() {
    for err := range errCh {
        //handle error
    }
}()

go hostHandler.RunForever(errCh)

Use in Routes

To use in a route, you can create a logger using the NewRouteLogger method.

For example:

http.HandleFunc("/foo", func(w http.ResponseWriter, r *http.Request){
    log := NewRouteLogger(r, logHandler)
    ...
})

About

Remote collecting Go logging.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages