Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCMD = &cobra.Command{ Use: "yeet", Short: "yeet is an in-memory indexed static file webserver", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { viper.SetConfigName("config") viper.AddConfigPath(".") viper.SetEnvPrefix("yeet") viper.AutomaticEnv() _ = viper.ReadInConfig() level, err := zerolog.ParseLevel(viper.GetString("log")) if err != nil { panic(err) } zerolog.SetGlobalLevel(level) writers := make([]io.Writer, 0) if !viper.GetBool("quiet") { writers = append(writers, zerolog.ConsoleWriter{ Out: os.Stdout, TimeFormat: time.RFC3339, }) } if viper.GetString("log-file") != "" { logFile, err := os.OpenFile(viper.GetString("log-file"), os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { return errors.Wrap(err, "failed to open log file") } writers = append(writers, logFile) } log.Logger = zerolog.New(io.MultiWriter(writers...)).With().Timestamp().Logger() return nil }, }
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.