Add log path config (#745)
Go CI / Lint (push) Has been cancelled
Go CI / Check (push) Has been cancelled
Go CI / Test (mysql, 1.26, mysql:8, ubuntu-latest, 3306:3306) (push) Has been cancelled
Go CI / Test (postgres, 1.26, postgres:16, ubuntu-latest, 5432:5432) (push) Has been cancelled
Go CI / Test (sqlite, 1.26, macOS-latest) (push) Has been cancelled
Go CI / Test (sqlite, 1.26, ubuntu-latest) (push) Has been cancelled
Go CI / Build (1.26, macOS-latest) (push) Has been cancelled
Go CI / Build (1.26, ubuntu-latest) (push) Has been cancelled
Go CI / Build (1.26, windows-latest) (push) Has been cancelled

This commit is contained in:
Thomas
2026-06-28 02:48:00 +07:00
committed by GitHub
parent 4b5a4377ba
commit cc03c1e910
3 changed files with 11 additions and 2 deletions
+3
View File
@@ -8,6 +8,9 @@ log-level: warn
# Set the log output to one or more of the following: `stdout`, `file`. Default: stdout,file
log-output: stdout,file
# Set the directory where the log file (opengist.log) is written. Default: $OG_OPENGIST_HOME/log
log-path:
# Public URL to access to Opengist
external-url:
+1
View File
@@ -8,6 +8,7 @@ aside: false
|--------------------------|-------------------------------------|-----------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| log-level | OG_LOG_LEVEL | `warn` | Set the log level to one of the following: `debug`, `info`, `warn`, `error`, `fatal`. |
| log-output | OG_LOG_OUTPUT | `stdout,file` | Set the log output to one or more of the following: `stdout`, `file`. |
| log-path | OG_LOG_PATH | `$opengist-home/log` | Set the directory where the log file (`opengist.log`) is written. |
| external-url | OG_EXTERNAL_URL | none | Public URL to access to Opengist. |
| opengist-home | OG_OPENGIST_HOME | home directory | Path to the directory where Opengist stores its data. |
| secret-key | OG_SECRET_KEY | randomized 32 bytes | Secret key used for session store & encrypt MFA data on database. |
+7 -2
View File
@@ -41,6 +41,7 @@ type config struct {
LogLevel string `yaml:"log-level" env:"OG_LOG_LEVEL"`
LogOutput string `yaml:"log-output" env:"OG_LOG_OUTPUT"`
LogPath string `yaml:"log-path" env:"OG_LOG_PATH"`
ExternalUrl string `yaml:"external-url" env:"OG_EXTERNAL_URL"`
OpengistHome string `yaml:"opengist-home" env:"OG_OPENGIST_HOME"`
@@ -205,6 +206,10 @@ func InitConfig(configPath string, out io.Writer) error {
C = c
if c.LogPath == "" {
c.LogPath = filepath.Join(GetHomeDir(), "log")
}
if err = migrateConfig(); err != nil {
return err
}
@@ -216,7 +221,7 @@ func InitConfig(configPath string, out io.Writer) error {
}
func InitLog() {
if err := os.MkdirAll(filepath.Join(GetHomeDir(), "log"), 0755); err != nil {
if err := os.MkdirAll(C.LogPath, 0755); err != nil {
panic(err)
}
@@ -257,7 +262,7 @@ func InitLog() {
logWriters = append(logWriters, consoleWriter)
defer func() { log.Debug().Msg("Logging to stdout") }()
case "file":
file, err := os.OpenFile(filepath.Join(GetHomeDir(), "log", "opengist.log"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
file, err := os.OpenFile(filepath.Join(C.LogPath, "opengist.log"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
panic(err)
}