-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |