Merge pull request #1838 from prometheus/release-1.0
Explicitly add logging flags to our custom flag set
This commit is contained in:
commit
12709af249
|
@ -238,6 +238,9 @@ func init() {
|
||||||
&cfg.queryEngine.MaxConcurrentQueries, "query.max-concurrency", 20,
|
&cfg.queryEngine.MaxConcurrentQueries, "query.max-concurrency", 20,
|
||||||
"Maximum number of queries executed concurrently.",
|
"Maximum number of queries executed concurrently.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Flags from the log package have to be added explicitly to our custom flag set.
|
||||||
|
log.AddFlags(cfg.fs)
|
||||||
}
|
}
|
||||||
|
|
||||||
func parse(args []string) error {
|
func parse(args []string) error {
|
||||||
|
|
|
@ -91,10 +91,16 @@ func (f logFormatFlag) Set(format string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// In order for these flags to take effect, the user of the package must call
|
AddFlags(flag.CommandLine)
|
||||||
// flag.Parse() before logging anything.
|
}
|
||||||
flag.Var(levelFlag{}, "log.level", "Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal].")
|
|
||||||
flag.Var(logFormatFlag{}, "log.format", "If set use a syslog logger or JSON logging. Example: logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to stderr.")
|
// AddFlags adds the flags used by this package to the given FlagSet. That's
|
||||||
|
// useful if working with a custom FlagSet. The init function of this package
|
||||||
|
// adds the flags to flag.CommandLine anyway. Thus, it's usually enough to call
|
||||||
|
// flag.Parse() to make the logging flags take effect.
|
||||||
|
func AddFlags(fs *flag.FlagSet) {
|
||||||
|
fs.Var(levelFlag{}, "log.level", "Only log messages with the given severity or above. Valid levels: [debug, info, warn, error, fatal].")
|
||||||
|
fs.Var(logFormatFlag{}, "log.format", "If set use a syslog logger or JSON logging. Example: logger:syslog?appname=bob&local=7 or logger:stdout?json=true. Defaults to stderr.")
|
||||||
}
|
}
|
||||||
|
|
||||||
type Logger interface {
|
type Logger interface {
|
||||||
|
|
|
@ -175,10 +175,10 @@
|
||||||
"revisionTime": "2016-06-23T15:14:27Z"
|
"revisionTime": "2016-06-23T15:14:27Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "qHoBp/PVBcLedTNZrF3toV9QGa0=",
|
"checksumSHA1": "fKMoxZehNhXbklRQy7lpFAVH0XY=",
|
||||||
"path": "github.com/prometheus/common/log",
|
"path": "github.com/prometheus/common/log",
|
||||||
"revision": "4402f4e5ea79ec15f3c574773b6a5198fbea215f",
|
"revision": "610701b0cb96fe82d0166b8e07979b174b6f06ae",
|
||||||
"revisionTime": "2016-06-23T15:14:27Z"
|
"revisionTime": "2016-07-20T15:23:54Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "Jx0GXl5hGnO25s3ryyvtdWHdCpw=",
|
"checksumSHA1": "Jx0GXl5hGnO25s3ryyvtdWHdCpw=",
|
||||||
|
|
Loading…
Reference in New Issue