mirror of
https://github.com/gluster/glusterd2.git
synced 2026-02-06 15:46:00 +01:00
GD2 can be configured using config files. The very good spf13/viper
package has been used to provide this facility.
GD2 will search for a file named "glusterdconf.(toml|yaml|json)" in
"/etc/glusterd" and the current working directory by default. A specific
config file can also be given using the `--config` flag on the command
line.
All of the command line flags, can also be configured in the config
file. The preference for values will be in the order
Flags > Config file > Coded defaults
The glusterd/config package has been removed. Any GD2 package requiring
access to the config needs to now import the spf13/viper package and use
the relevant Get* function to get the configuration.
For eg.
```go
import config "github.com/spf13/viper"
func someFunc() {
rpcAddress := config.GetString("rpcaddress")
}
```
18 lines
302 B
Go
18 lines
302 B
Go
package main
|
|
|
|
import (
|
|
"io"
|
|
"strings"
|
|
|
|
log "github.com/Sirupsen/logrus"
|
|
)
|
|
|
|
func initLog(logLevel string, out io.Writer) {
|
|
l, err := log.ParseLevel(strings.ToLower(logLevel))
|
|
if err != nil {
|
|
log.WithField("error", err).Fatal("Failed to parse log level")
|
|
}
|
|
log.SetLevel(l)
|
|
log.SetOutput(out)
|
|
}
|