1
0
mirror of https://github.com/gluster/glusterd2.git synced 2026-02-06 15:46:00 +01:00
Files
glusterd2/logging.go
Kaushal M 2122fd2afb Add support for config files
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")
}
```
2016-06-24 20:47:08 +05:30

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)
}