1
0

Defering such things is more gopher way.

This commit is contained in:
Alexander Andreev 2022-02-10 22:51:38 +04:00
parent 5f8b6d2b09
commit 2c567fd1e5
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -30,6 +30,7 @@ func NewLogger(path string, toStdout bool) (*Logger, error) {
func (l *Logger) Println(v ...interface{}) {
l.mut.Lock()
defer l.mut.Unlock()
nowStr := time.Now().UTC().Format(time.RFC3339)
@ -38,12 +39,11 @@ func (l *Logger) Println(v ...interface{}) {
if l.toStdout {
fmt.Println(nowStr, v)
}
l.mut.Unlock()
}
func (l *Logger) Printf(format string, v ...interface{}) {
l.mut.Lock()
defer l.mut.Unlock()
// Ensure a new line will be written
if !strings.HasSuffix(format, "\n") {
@ -57,8 +57,6 @@ func (l *Logger) Printf(format string, v ...interface{}) {
if l.toStdout {
fmt.Printf(nowStr+" "+format, v...)
}
l.mut.Unlock()
}
func (l *Logger) Fatalln(v ...interface{}) {