You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am logging console as well as txt log file.Console output is okay and it is colored however, txt output is broken. Here is the output: log.txt
Here is the code to setup logger:
// InitLogger setup logger for both printing file and console
func InitLogger(path string, methodname bool) {
// remove old file if exist
os.Remove(path)
// set formatter of logger
log.SetFormatter(&log.TextFormatter{
ForceColors: true,
DisableTimestamp: true,
})
// open logging file
f, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0666)
// check error
CheckError(err)
// defer f.Close()
// log both file and console
wrt := io.MultiWriter(os.Stdout, f)
// set output
log.SetOutput(wrt)
// set whether we log filename as well
log.SetReportCaller(methodname)
// log.SetLevel(log.ErrorLevel)
log.Info("Logger has been initilized.")
}
The text was updated successfully, but these errors were encountered:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am logging console as well as txt log file.Console output is okay and it is colored however, txt output is broken. Here is the output:
log.txt
Here is the code to setup logger:
The text was updated successfully, but these errors were encountered: