Skip to content

A small library to bridge Go's log package to github.com/apex/log.

License

Notifications You must be signed in to change notification settings

avct/stdlogtoapex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stdlogtoapex

A small library to bridge Go's log package to github.com/apex/log.

Redirecting standard log messages to apex log.

stdlogtoapex provides Writer type that implements the io.Writer interface and can be passed to the standard library log.SetOutput function. When this is done, all subsequent calls to the log packages output functions will send their output to via this Writer, and it will, in turn, log that output via Apex log's default handler.

Example

package main

import (
    "log"
    ]
    "github.com/avct/stdlogtoapex"
    alog "github.com/apex/log"
    "github.com/apex/log/handlers/cli"
)

func main() {
    handler := cli.Default
	alog.SetHandler(handler)
	writer := stdlogtoapex.NewWriter()
    
    // From this point all output from the standard library log package will be ouptup via the Writer
	log.SetOutput(writer)
	log.Print("Hello!")
}

Caveat

This package will not capture logging sent via the "log/syslog" package.

About

A small library to bridge Go's log package to github.com/apex/log.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages