package main import ( "flag" "fmt" "log/slog" "net/http" "os" "strings" "git.runcible.io/learning/ratchet" ratchethttp "git.runcible.io/learning/ratchet/internal" ) var ( version string commit string ) func main() { // Commandline options addr := flag.String("addr", "0.0.0.0", "HTTP network address") port := flag.String("port", "5001", "HTTP port") logLevel := flag.String("logging", "INFO", "Logging Level. Valid values [INFO, DEBUG, WARN, ERROR].") // must call parse or all values will be the defaults flag.Parse() // Setup Logging ratchethttp.InitLogging(*logLevel) // Propagate build information to root package to share globally ratchet.Version = strings.TrimPrefix(version, "") ratchet.Commit = commit server := ratchethttp.NewRatchetServer() slog.Debug("Herp dirp!") slog.Info(fmt.Sprintf("Listening on http://%s:%s", *addr, *port)) //log.Fatal(http.ListenAndServe(fmt.Sprintf("%s:%s", *addr, *port), server)) // there is no log.Fatal equivalent. This is an approximation of the behavior err := http.ListenAndServe(fmt.Sprintf("%s:%s", *addr, *port), server) slog.Error(err.Error()) os.Exit(1) }