mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 14:39:40 -08:00
vendor: Update common/log
Signed-off-by: Goutham Veeramachaneni <cs14btech11014@iith.ac.in>
This commit is contained in:
parent
ea255c6520
commit
c399563ec1
10
vendor/github.com/prometheus/common/log/eventlog_formatter.go
generated
vendored
10
vendor/github.com/prometheus/common/log/eventlog_formatter.go
generated
vendored
|
@ -21,22 +21,22 @@ import (
|
||||||
|
|
||||||
"golang.org/x/sys/windows/svc/eventlog"
|
"golang.org/x/sys/windows/svc/eventlog"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
setEventlogFormatter = func(name string, debugAsInfo bool) error {
|
setEventlogFormatter = func(l logger, name string, debugAsInfo bool) error {
|
||||||
if name == "" {
|
if name == "" {
|
||||||
return fmt.Errorf("missing name parameter")
|
return fmt.Errorf("missing name parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
fmter, err := newEventlogger(name, debugAsInfo, origLogger.Formatter)
|
fmter, err := newEventlogger(name, debugAsInfo, l.entry.Logger.Formatter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error creating eventlog formatter: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error creating eventlog formatter: %v\n", err)
|
||||||
origLogger.Errorf("can't connect logger to eventlog: %v", err)
|
l.Errorf("can't connect logger to eventlog: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
origLogger.Formatter = fmter
|
l.entry.Logger.Formatter = fmter
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
101
vendor/github.com/prometheus/common/log/log.go
generated
vendored
101
vendor/github.com/prometheus/common/log/log.go
generated
vendored
|
@ -25,7 +25,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type levelFlag string
|
type levelFlag string
|
||||||
|
@ -46,10 +46,10 @@ func (f levelFlag) Set(level string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// setSyslogFormatter is nil if the target architecture does not support syslog.
|
// setSyslogFormatter is nil if the target architecture does not support syslog.
|
||||||
var setSyslogFormatter func(string, string) error
|
var setSyslogFormatter func(logger, string, string) error
|
||||||
|
|
||||||
// setEventlogFormatter is nil if the target OS does not support Eventlog (i.e., is not Windows).
|
// setEventlogFormatter is nil if the target OS does not support Eventlog (i.e., is not Windows).
|
||||||
var setEventlogFormatter func(string, bool) error
|
var setEventlogFormatter func(logger, string, bool) error
|
||||||
|
|
||||||
func setJSONFormatter() {
|
func setJSONFormatter() {
|
||||||
origLogger.Formatter = &logrus.JSONFormatter{}
|
origLogger.Formatter = &logrus.JSONFormatter{}
|
||||||
|
@ -65,45 +65,7 @@ func (f logFormatFlag) String() string {
|
||||||
|
|
||||||
// Set implements flag.Value.
|
// Set implements flag.Value.
|
||||||
func (f logFormatFlag) Set(format string) error {
|
func (f logFormatFlag) Set(format string) error {
|
||||||
u, err := url.Parse(format)
|
return baseLogger.SetFormat(format)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if u.Scheme != "logger" {
|
|
||||||
return fmt.Errorf("invalid scheme %s", u.Scheme)
|
|
||||||
}
|
|
||||||
jsonq := u.Query().Get("json")
|
|
||||||
if jsonq == "true" {
|
|
||||||
setJSONFormatter()
|
|
||||||
}
|
|
||||||
|
|
||||||
switch u.Opaque {
|
|
||||||
case "syslog":
|
|
||||||
if setSyslogFormatter == nil {
|
|
||||||
return fmt.Errorf("system does not support syslog")
|
|
||||||
}
|
|
||||||
appname := u.Query().Get("appname")
|
|
||||||
facility := u.Query().Get("local")
|
|
||||||
return setSyslogFormatter(appname, facility)
|
|
||||||
case "eventlog":
|
|
||||||
if setEventlogFormatter == nil {
|
|
||||||
return fmt.Errorf("system does not support eventlog")
|
|
||||||
}
|
|
||||||
name := u.Query().Get("name")
|
|
||||||
debugAsInfo := false
|
|
||||||
debugAsInfoRaw := u.Query().Get("debugAsInfo")
|
|
||||||
if parsedDebugAsInfo, err := strconv.ParseBool(debugAsInfoRaw); err == nil {
|
|
||||||
debugAsInfo = parsedDebugAsInfo
|
|
||||||
}
|
|
||||||
return setEventlogFormatter(name, debugAsInfo)
|
|
||||||
case "stdout":
|
|
||||||
origLogger.Out = os.Stdout
|
|
||||||
case "stderr":
|
|
||||||
origLogger.Out = os.Stderr
|
|
||||||
default:
|
|
||||||
return fmt.Errorf("unsupported logger %q", u.Opaque)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -150,6 +112,9 @@ type Logger interface {
|
||||||
Fatalf(string, ...interface{})
|
Fatalf(string, ...interface{})
|
||||||
|
|
||||||
With(key string, value interface{}) Logger
|
With(key string, value interface{}) Logger
|
||||||
|
|
||||||
|
SetFormat(string) error
|
||||||
|
SetLevel(string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type logger struct {
|
type logger struct {
|
||||||
|
@ -235,6 +200,58 @@ func (l logger) Fatalf(format string, args ...interface{}) {
|
||||||
l.sourced().Fatalf(format, args...)
|
l.sourced().Fatalf(format, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l logger) SetLevel(level string) error {
|
||||||
|
lvl, err := logrus.ParseLevel(level)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
l.entry.Logger.Level = lvl
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l logger) SetFormat(format string) error {
|
||||||
|
u, err := url.Parse(format)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if u.Scheme != "logger" {
|
||||||
|
return fmt.Errorf("invalid scheme %s", u.Scheme)
|
||||||
|
}
|
||||||
|
jsonq := u.Query().Get("json")
|
||||||
|
if jsonq == "true" {
|
||||||
|
setJSONFormatter()
|
||||||
|
}
|
||||||
|
|
||||||
|
switch u.Opaque {
|
||||||
|
case "syslog":
|
||||||
|
if setSyslogFormatter == nil {
|
||||||
|
return fmt.Errorf("system does not support syslog")
|
||||||
|
}
|
||||||
|
appname := u.Query().Get("appname")
|
||||||
|
facility := u.Query().Get("local")
|
||||||
|
return setSyslogFormatter(l, appname, facility)
|
||||||
|
case "eventlog":
|
||||||
|
if setEventlogFormatter == nil {
|
||||||
|
return fmt.Errorf("system does not support eventlog")
|
||||||
|
}
|
||||||
|
name := u.Query().Get("name")
|
||||||
|
debugAsInfo := false
|
||||||
|
debugAsInfoRaw := u.Query().Get("debugAsInfo")
|
||||||
|
if parsedDebugAsInfo, err := strconv.ParseBool(debugAsInfoRaw); err == nil {
|
||||||
|
debugAsInfo = parsedDebugAsInfo
|
||||||
|
}
|
||||||
|
return setEventlogFormatter(l, name, debugAsInfo)
|
||||||
|
case "stdout":
|
||||||
|
l.entry.Logger.Out = os.Stdout
|
||||||
|
case "stderr":
|
||||||
|
l.entry.Logger.Out = os.Stderr
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unsupported logger %q", u.Opaque)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// sourced adds a source field to the logger that contains
|
// sourced adds a source field to the logger that contains
|
||||||
// the file name and line where the logging happened.
|
// the file name and line where the logging happened.
|
||||||
func (l logger) sourced() *logrus.Entry {
|
func (l logger) sourced() *logrus.Entry {
|
||||||
|
|
10
vendor/github.com/prometheus/common/log/syslog_formatter.go
generated
vendored
10
vendor/github.com/prometheus/common/log/syslog_formatter.go
generated
vendored
|
@ -20,13 +20,13 @@ import (
|
||||||
"log/syslog"
|
"log/syslog"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ logrus.Formatter = (*syslogger)(nil)
|
var _ logrus.Formatter = (*syslogger)(nil)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
setSyslogFormatter = func(appname, local string) error {
|
setSyslogFormatter = func(l logger, appname, local string) error {
|
||||||
if appname == "" {
|
if appname == "" {
|
||||||
return fmt.Errorf("missing appname parameter")
|
return fmt.Errorf("missing appname parameter")
|
||||||
}
|
}
|
||||||
|
@ -34,13 +34,13 @@ func init() {
|
||||||
return fmt.Errorf("missing local parameter")
|
return fmt.Errorf("missing local parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
fmter, err := newSyslogger(appname, local, origLogger.Formatter)
|
fmter, err := newSyslogger(appname, local, l.entry.Logger.Formatter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error creating syslog formatter: %v\n", err)
|
fmt.Fprintf(os.Stderr, "error creating syslog formatter: %v\n", err)
|
||||||
origLogger.Errorf("can't connect logger to syslog: %v", err)
|
l.entry.Errorf("can't connect logger to syslog: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
origLogger.Formatter = fmter
|
l.entry.Logger.Formatter = fmter
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
6
vendor/vendor.json
vendored
6
vendor/vendor.json
vendored
|
@ -727,10 +727,10 @@
|
||||||
"revisionTime": "2017-04-18T15:52:10Z"
|
"revisionTime": "2017-04-18T15:52:10Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "vfkLfDs6hXtxdJNGdWQglsxFu40=",
|
"checksumSHA1": "esljoY35OOHttvpjBctA6WGZc70=",
|
||||||
"path": "github.com/prometheus/common/log",
|
"path": "github.com/prometheus/common/log",
|
||||||
"revision": "75882ff176da1a10e2705adadd81edfd3a50d743",
|
"revision": "94eb3fe3a55f1b5d12d335b27a4f6e37cd73ed7e",
|
||||||
"revisionTime": "2017-04-27T09:48:40Z"
|
"revisionTime": "2017-06-16T09:39:39Z"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"checksumSHA1": "0LL9u9tfv1KPBjNEiMDP6q7lpog=",
|
"checksumSHA1": "0LL9u9tfv1KPBjNEiMDP6q7lpog=",
|
||||||
|
|
Loading…
Reference in a new issue