Ejemplo n.º 1
0
func loadConfig(client *etcd.Client, config *Config) (*Config, error) {
	config.log = log.New("skydns", false,
		log.CombinedSink(os.Stderr, "[%s] %s %-9s | %s\n", []string{"prefix", "time", "priority", "message"}))

	// Override wat isn't set yet from the command line.
	n, err := client.Get("/skydns/config", false, false)
	if err != nil {
		config.log.Info("falling back to default configuration, could not read from etcd:", err)
		if err := setDefaults(config); err != nil {
			return nil, err
		}
		return config, nil
	}
	if err := json.Unmarshal([]byte(n.Node.Value), &config); err != nil {
		return nil, err
	}
	if err := setDefaults(config); err != nil {
		return nil, err
	}
	return config, nil
}
Ejemplo n.º 2
0
func LoadConfig(client *etcd.Client) (*Config, error) {
	config := &Config{ReadTimeout: 0, Domain: "", DnsAddr: "", DNSSEC: ""}
	config.log = log.New("skydns", false,
		log.CombinedSink(os.Stderr, "[%s] %s %-9s | %s\n", []string{"prefix", "time", "priority", "message"}))

	n, err := client.Get("/skydns/config", false, false)
	if err != nil {
		config.log.Info("falling back to default configuration")
		if err := setDefaults(config); err != nil {
			return nil, err
		}
		return config, nil
	}
	if err := json.Unmarshal([]byte(n.Node.Value), &config); err != nil {
		return nil, err
	}
	if err := setDefaults(config); err != nil {
		return nil, err
	}
	return config, nil
}
Ejemplo n.º 3
0
package log

import (
	golog "github.com/coreos/go-log/log"
	"os"
)

// The Verbose flag turns on verbose logging.
var Verbose bool = false

var logger *golog.Logger = golog.New("etcd", false,
	golog.CombinedSink(os.Stdout, "[%s] %s %-9s | %s\n", []string{"prefix", "time", "priority", "message"}))

func Infof(format string, v ...interface{}) {
	logger.Infof(format, v...)
}

func Debugf(format string, v ...interface{}) {
	if Verbose {
		logger.Debugf(format, v...)
	}
}

func Debug(v ...interface{}) {
	if Verbose {
		logger.Debug(v...)
	}
}

func Warnf(format string, v ...interface{}) {
	logger.Warningf(format, v...)