mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-30 15:12:27 -08:00
Merge pull request #1283 from prometheus/venup
Upgrade common/log vendoring.
This commit is contained in:
commit
0109300963
22
vendor/github.com/prometheus/common/log/log.go
generated
vendored
22
vendor/github.com/prometheus/common/log/log.go
generated
vendored
|
@ -41,23 +41,8 @@ func (f levelFlag) Set(level string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func setSyslogFormatter(appname, local string) error {
|
// setSyslogFormatter is nil if the target architecture does not support syslog.
|
||||||
if appname == "" {
|
var setSyslogFormatter func(string, string) error
|
||||||
return fmt.Errorf("missing appname parameter")
|
|
||||||
}
|
|
||||||
if local == "" {
|
|
||||||
return fmt.Errorf("missing local parameter")
|
|
||||||
}
|
|
||||||
|
|
||||||
fmter, err := newSyslogger(appname, local, origLogger.Formatter)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintf(os.Stderr, "error creating syslog formatter: %v\n", err)
|
|
||||||
origLogger.Errorf("can't connect logger to syslog: %v", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
origLogger.Formatter = fmter
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func setJSONFormatter() {
|
func setJSONFormatter() {
|
||||||
origLogger.Formatter = &logrus.JSONFormatter{}
|
origLogger.Formatter = &logrus.JSONFormatter{}
|
||||||
|
@ -87,6 +72,9 @@ func (f logFormatFlag) Set(format string) error {
|
||||||
|
|
||||||
switch u.Opaque {
|
switch u.Opaque {
|
||||||
case "syslog":
|
case "syslog":
|
||||||
|
if setSyslogFormatter == nil {
|
||||||
|
return fmt.Errorf("system does not support syslog")
|
||||||
|
}
|
||||||
appname := u.Query().Get("appname")
|
appname := u.Query().Get("appname")
|
||||||
facility := u.Query().Get("local")
|
facility := u.Query().Get("local")
|
||||||
return setSyslogFormatter(appname, facility)
|
return setSyslogFormatter(appname, facility)
|
||||||
|
|
35
vendor/github.com/prometheus/common/log/syslog_formatter.go
generated
vendored
35
vendor/github.com/prometheus/common/log/syslog_formatter.go
generated
vendored
|
@ -1,3 +1,18 @@
|
||||||
|
// Copyright 2015 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.
|
||||||
|
|
||||||
|
// +build !windows,!nacl,!plan9
|
||||||
|
|
||||||
package log
|
package log
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -8,6 +23,26 @@ import (
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
setSyslogFormatter = func(appname, local string) error {
|
||||||
|
if appname == "" {
|
||||||
|
return fmt.Errorf("missing appname parameter")
|
||||||
|
}
|
||||||
|
if local == "" {
|
||||||
|
return fmt.Errorf("missing local parameter")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmter, err := newSyslogger(appname, local, origLogger.Formatter)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "error creating syslog formatter: %v\n", err)
|
||||||
|
origLogger.Errorf("can't connect logger to syslog: %v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
origLogger.Formatter = fmter
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var ceeTag = []byte("@cee:")
|
var ceeTag = []byte("@cee:")
|
||||||
|
|
||||||
type syslogger struct {
|
type syslogger struct {
|
||||||
|
|
4
vendor/vendor.json
vendored
4
vendor/vendor.json
vendored
|
@ -164,8 +164,8 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "github.com/prometheus/common/log",
|
"path": "github.com/prometheus/common/log",
|
||||||
"revision": "4fdc91a58c9d3696b982e8a680f4997403132d44",
|
"revision": "0a3005bb37bc411040083a55372e77c405f6464c",
|
||||||
"revisionTime": "2015-10-26T12:04:34+01:00"
|
"revisionTime": "2016-01-04T14:47:38+01:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "github.com/prometheus/common/model",
|
"path": "github.com/prometheus/common/model",
|
||||||
|
|
Loading…
Reference in a new issue