// initLogs initializes the logs map. func (b *Broker) initLogs() { pattern := filepath.Join(b.config.LogDir(), "*"+EXT) matches, err := filepath.Glob(pattern) if nil != err { log.Panic("Unable to read from log directory: %s", b.config.LogDir()) } for _, name := range matches { topic := filepath.Base(name) topic = topic[0 : len(topic)-len(EXT)] file, err := OpenLog(b.config, topic, -1) if nil != err { log.Error("Ignoring bad log file: %s", name) continue } b.logs[topic] = file log.Info("Found log file for %s.", topic) } }
// origin returns the hostname func origin() string { name, err := os.Hostname() if nil != err { log.Panic(err.Error()) } return "ws://" + name }