Merge pull request #228 from prometheus/vendorup
Update common/log vendoring
This commit is contained in:
commit
44388e07a9
|
@ -41,23 +41,8 @@ func (f levelFlag) Set(level string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func setSyslogFormatter(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
|
||||
}
|
||||
// setSyslogFormatter is nil if the target architecture does not support syslog.
|
||||
var setSyslogFormatter func(string, string) error
|
||||
|
||||
func setJSONFormatter() {
|
||||
origLogger.Formatter = &logrus.JSONFormatter{}
|
||||
|
@ -87,6 +72,9 @@ func (f logFormatFlag) Set(format string) error {
|
|||
|
||||
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)
|
||||
|
|
|
@ -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
|
||||
|
||||
import (
|
||||
|
@ -8,6 +23,26 @@ import (
|
|||
"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:")
|
||||
|
||||
type syslogger struct {
|
||||
|
|
|
@ -64,8 +64,8 @@
|
|||
},
|
||||
{
|
||||
"path": "github.com/prometheus/common/log",
|
||||
"revision": "4fdc91a58c9d3696b982e8a680f4997403132d44",
|
||||
"revisionTime": "2015-10-26T12:04:34+01:00"
|
||||
"revision": "0a3005bb37bc411040083a55372e77c405f6464c",
|
||||
"revisionTime": "2016-01-04T14:47:38+01:00"
|
||||
},
|
||||
{
|
||||
"path": "github.com/prometheus/common/model",
|
||||
|
|
Loading…
Reference in New Issue