@@ -53,7 +53,7 @@ func CLIFlagsWithCategory(envPrefix string, category string) []cli.Flag {
5353 },
5454 & cli.GenericFlag {
5555 Name : FormatFlagName ,
56- Usage : "Format the log output. Supported formats: 'text', 'terminal', 'logfmt', 'json', 'json-pretty'," ,
56+ Usage : fmt . Sprintf ( "Format the log output. Supported formats: %s" , SupportedFormatsString ()) ,
5757 Value : NewFormatFlagValue (FormatText ),
5858 EnvVars : opservice .PrefixEnvVar (envPrefix , "LOG_FORMAT" ),
5959 Category : category ,
@@ -144,6 +144,25 @@ const (
144144 FormatJSONMs FormatType = "jsonms"
145145)
146146
147+ // All supported format types in a slice for iteration
148+ var formatTypes = []FormatType {
149+ FormatText ,
150+ FormatTerminal ,
151+ FormatLogFmt ,
152+ FormatLogFmtMs ,
153+ FormatJSON ,
154+ FormatJSONMs ,
155+ }
156+
157+ // SupportedFormatsString returns a comma-delimited string of supported formats,
158+ func SupportedFormatsString () string {
159+ names := make ([]string , 0 , len (formatTypes ))
160+ for _ , f := range formatTypes {
161+ names = append (names , f .String ())
162+ }
163+ return strings .Join (names , ", " )
164+ }
165+
147166// FormatHandler returns the correct slog handler factory for the provided format.
148167func FormatHandler (ft FormatType , color bool ) func (io.Writer ) slog.Handler {
149168 termColorHandler := func (w io.Writer ) slog.Handler {
0 commit comments