-
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
6 changed files
with
93 additions
and
30 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 |
---|---|---|
|
@@ -33,4 +33,6 @@ data/ | |
venv/ | ||
.venv/ | ||
|
||
logs/ | ||
|
||
site/ |
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
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
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,30 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
"time" | ||
) | ||
|
||
func getLogFilePath(logParamPath *string) string { | ||
// ログフォルダパスは環境変数 LOG_PATH または引数 -log で指定し、指定されていない場合は "logs/" とする。 | ||
// "logs/" の場所は、実行ファイルと同じディレクトリにあるものとする。go runで実行する場合は、カレントディレクトリにあるものとする。 | ||
// ログファイルのファイル名は、yyyy-mm-dd.log とする。 | ||
if *logParamPath != "" { | ||
return *logParamPath | ||
} | ||
|
||
date := time.Now().Format("2006-01-02") | ||
|
||
exePath, err := os.Executable() | ||
if err != nil { | ||
return filepath.Join("logs", date+".log") | ||
} | ||
|
||
if isGoRun() { | ||
return filepath.Join("logs", date+".log") | ||
} | ||
|
||
exeDir := filepath.Dir(exePath) | ||
return filepath.Join(exeDir, "logs", date+".log") | ||
} |
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
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