2020-05-01 06:12:16 +00:00
|
|
|
package log
|
2017-02-25 05:56:40 +00:00
|
|
|
|
|
|
|
import (
|
2017-03-27 21:09:25 +00:00
|
|
|
"io"
|
2017-02-25 05:56:40 +00:00
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2017-03-27 21:09:25 +00:00
|
|
|
//Logoutput -- passing the output writer from main
|
2020-05-01 06:12:16 +00:00
|
|
|
Loginfo *log.Logger
|
|
|
|
Logdebug *log.Logger
|
|
|
|
LogFlags = log.Ldate | log.Lmicroseconds | log.Lshortfile
|
2017-02-25 05:56:40 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2020-05-01 06:12:16 +00:00
|
|
|
Loginfo = log.New(os.Stdout, "INFO: ", LogFlags)
|
|
|
|
Logdebug = log.New(os.Stdout, "DEBUG: ", LogFlags)
|
2017-02-25 05:56:40 +00:00
|
|
|
}
|
2017-03-27 21:09:25 +00:00
|
|
|
|
|
|
|
//InitLogging -- after main sets up output, it will init all packages InitLogging
|
|
|
|
//I am sure I am doing this wrong, but I could not find a way to have package level
|
|
|
|
//logging with the flags I wanted and the ability to run lumberjack file management
|
|
|
|
func InitLogging(logoutput io.Writer) {
|
2020-05-01 06:12:16 +00:00
|
|
|
Loginfo.SetOutput(logoutput)
|
2017-03-27 21:09:25 +00:00
|
|
|
}
|