Skip to content

Commit

Permalink
crate logging
Browse files Browse the repository at this point in the history
  • Loading branch information
takumism committed Aug 13, 2019
1 parent 1b3eace commit 44e24b3
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions utils/logging.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package utils

import (
"io"
"log"
"os"
)

func LoggingSetting(logFile string) {
// ログファイルを読み書き可能な形で開く
logfile, err := os.OpenFile(logFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatalf("file=logFile err=%s", err.Error())
}
// 実行時とログファイルに書き込む
multiLogFile := io.MultiWriter(os.Stdout, logfile)
// 書き込み設定
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
log.SetOutput(multiLogFile)
}

0 comments on commit 44e24b3

Please sign in to comment.