2023-04-22 10:17:51 +00:00
|
|
|
// Copyright 2017 The Prometheus Authors
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package flag
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/alecthomas/kingpin/v2"
|
2023-11-04 19:51:35 +00:00
|
|
|
"github.com/prometheus-community/windows_exporter/pkg/log"
|
2024-09-10 22:34:10 +00:00
|
|
|
"github.com/prometheus/common/promslog"
|
|
|
|
"github.com/prometheus/common/promslog/flag"
|
2023-04-22 10:17:51 +00:00
|
|
|
)
|
|
|
|
|
2024-08-10 20:05:33 +00:00
|
|
|
// FileFlagName is the canonical flag name to configure the log file.
|
2023-04-22 10:17:51 +00:00
|
|
|
const FileFlagName = "log.file"
|
|
|
|
|
|
|
|
// FileFlagHelp is the help description for the log.file flag.
|
|
|
|
const FileFlagHelp = "Output file of log messages. One of [stdout, stderr, eventlog, <path to log file>]"
|
|
|
|
|
|
|
|
// AddFlags adds the flags used by this package to the Kingpin application.
|
2024-08-10 20:05:33 +00:00
|
|
|
// To use the default Kingpin application, call AddFlags(kingpin.CommandLine).
|
2023-04-22 10:17:51 +00:00
|
|
|
func AddFlags(a *kingpin.Application, config *log.Config) {
|
2024-09-10 22:34:10 +00:00
|
|
|
config.Config = new(promslog.Config)
|
|
|
|
flag.AddFlags(a, config.Config)
|
2023-04-22 10:17:51 +00:00
|
|
|
|
|
|
|
config.File = &log.AllowedFile{}
|
2024-09-10 22:34:10 +00:00
|
|
|
a.Flag(FileFlagName, FileFlagHelp).Default("stderr").SetValue(config.File)
|
2023-04-22 10:17:51 +00:00
|
|
|
}
|