func dial() *net.UDPConn { err, host := config.GetStringMapString("udp", "host") if err != nil { log.Error("can't find udp host") os.Exit(0) } err, port := config.GetStringMapString("udp", "port") if err != nil { log.Error("can't find udp port") os.Exit(0) } raddr, err := net.ResolveUDPAddr("udp", host+":"+port) if err != nil { log.Error("connect udp %s:%s error\n", host, port) os.Exit(0) } conn, err := net.DialUDP("udp", nil, raddr) if err != nil { log.Error("connect udp %s:%s error\n", host, port) os.Exit(0) } // bump up the packet size for large log lines err = conn.SetWriteBuffer(writeBuffer) if err != nil { log.Error("connect udp %s:%s error\n", host, port) os.Exit(0) } return conn }
func Stream(stream *chan types.Message) { e := echo.New() e.Get("/", func(c *echo.Context) error { c.Response().Header().Set(echo.ContentType, echo.ApplicationJSON) c.Response().WriteHeader(http.StatusOK) for s := range *stream { c.Response().Write(append([]byte(s.Text), '\n')) c.Response().Flush() } return nil }) err, host := config.GetStringMapString("httpstream", "host") if err != nil { host = "0.0.0.0" } err, port := config.GetStringMapString("httpstream", "port") if err != nil { log.Error("can't find port") os.Exit(0) } e.Run(host + ":" + port) }
func init() { _, console = config.GetStringMapBool("log", "console") _, appendfile = config.GetStringMapBool("log", "appendfile") _, file = config.GetStringMapString("log", "file") if file == "" { file = "./log/omega-es.log" } logger, err := log.LoggerFromConfigAsString(logConfig()) if err == nil { log.ReplaceLogger(logger) } else { log.Error(err) } }