本文整理汇总了Golang中github.com/coreos/pkg/capnslog.NewPackageLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang NewPackageLogger函数的具体用法?Golang NewPackageLogger怎么用?Golang NewPackageLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewPackageLogger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
log.SetFormatter(log.NewPrettyFormatter(os.Stdout, true))
apnsLogger = log.NewPackageLogger("apns-microservice", "apns")
serverLogger = log.NewPackageLogger("apns-microservice", "http")
log.SetGlobalLogLevel(log.INFO)
apns.SetLogger(apnsLogger)
server.SetLogger(serverLogger)
}
示例2: init
func init() {
raft.SetLogger(capnslog.NewPackageLogger("github.com/coreos/etcd", "raft"))
expvar.Publish("raft.status", expvar.Func(func() interface{} {
raftStatusMu.Lock()
defer raftStatusMu.Unlock()
return raftStatus()
}))
}
示例3: Example
func Example() {
var plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "clientv3")
clientv3.SetLogger(plog)
cli, err := clientv3.New(clientv3.Config{
Endpoints: endpoints,
DialTimeout: dialTimeout,
})
if err != nil {
log.Fatal(err)
}
defer cli.Close() // make sure to close the client
_, err = cli.Put(context.TODO(), "foo", "bar")
if err != nil {
log.Fatal(err)
}
}
示例4:
"fmt"
"net"
"net/http"
"path"
"github.com/coreos/etcd/etcdserver"
"github.com/coreos/etcd/etcdserver/api/v2http"
"github.com/coreos/etcd/pkg/cors"
runtimeutil "github.com/coreos/etcd/pkg/runtime"
"github.com/coreos/etcd/pkg/transport"
"github.com/coreos/etcd/pkg/types"
"github.com/coreos/etcd/rafthttp"
"github.com/coreos/pkg/capnslog"
)
var plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "embed")
const (
// internal fd usage includes disk usage and transport usage.
// To read/write snapshot, snap pkg needs 1. In normal case, wal pkg needs
// at most 2 to read/lock/write WALs. One case that it needs to 2 is to
// read all logs after some snapshot index, which locates at the end of
// the second last and the head of the last. For purging, it needs to read
// directory, so it needs 1. For fd monitor, it needs 1.
// For transport, rafthttp builds two long-polling connections and at most
// four temporary connections with each member. There are at most 9 members
// in a cluster, so it should reserve 96.
// For the safety, we set the total reserved number to 150.
reservedInternalFDNum = 150
)
示例5: inactivate
// See the License for the specific language governing permissions and
// limitations under the License.
package tcpproxy
import (
"io"
"net"
"sync"
"time"
"github.com/coreos/pkg/capnslog"
)
var (
plog = capnslog.NewPackageLogger("github.com/coreos/etcd/proxy", "tcpproxy")
)
type remote struct {
mu sync.Mutex
addr string
inactive bool
}
func (r *remote) inactivate() {
r.mu.Lock()
defer r.mu.Unlock()
r.inactive = true
}
func (r *remote) tryReactivate() error {
示例6: MustMarshal
//
// 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 pbutil defines interfaces for handling Protocol Buffer objects.
package pbutil
import "github.com/coreos/pkg/capnslog"
var (
plog = capnslog.NewPackageLogger("github.com/coreos/etcd/pkg", "pbutil")
)
type Marshaler interface {
Marshal() (data []byte, err error)
}
type Unmarshaler interface {
Unmarshal(data []byte) error
}
func MustMarshal(m Marshaler) []byte {
d, err := m.Marshal()
if err != nil {
plog.Panicf("marshal should never fail (%v)", err)
}
示例7:
// See the License for the specific language governing permissions and
// limitations under the License.
package redhatrelease
import (
"regexp"
"strings"
"github.com/coreos/clair/database"
"github.com/coreos/clair/worker/detectors"
"github.com/coreos/pkg/capnslog"
)
var (
log = capnslog.NewPackageLogger("github.com/coreos/clair", "worker/detectors/namespace/redhatrelease")
centosReleaseRegexp = regexp.MustCompile(`(?P<os>[^\s]*) (Linux release|release) (?P<version>[\d]+)`)
redhatReleaseRegexp = regexp.MustCompile(`(?P<os>Red Hat Enterprise Linux) (Client release|Server release|Workstation release) (?P<version>[\d]+)`)
)
// RedhatReleaseNamespaceDetector implements NamespaceDetector and detects the OS from the
// /etc/centos-release, /etc/redhat-release and /etc/system-release files.
//
// Typically for CentOS and Red-Hat like systems
// eg. CentOS release 5.11 (Final)
// eg. CentOS release 6.6 (Final)
// eg. CentOS Linux release 7.1.1503 (Core)
// eg. Red Hat Enterprise Linux Server release 7.2 (Maipo)
type RedhatReleaseNamespaceDetector struct{}
示例8:
import (
"encoding/json"
"fmt"
"net/http"
"time"
"github.com/coreos/pkg/capnslog"
"github.com/coreos/pkg/timeutil"
"github.com/jonboulle/clockwork"
phttp "github.com/coreos/go-oidc/http"
"github.com/coreos/go-oidc/oauth2"
)
var (
log = capnslog.NewPackageLogger("github.com/coreos/go-oidc", "http")
)
const (
MaximumProviderConfigSyncInterval = 24 * time.Hour
MinimumProviderConfigSyncInterval = time.Minute
discoveryConfigPath = "/.well-known/openid-configuration"
)
// internally configurable for tests
var minimumProviderConfigSyncInterval = MinimumProviderConfigSyncInterval
type ProviderConfig struct {
Issuer string `json:"issuer"`
AuthEndpoint string `json:"authorization_endpoint"`
示例9: init
func init() {
grpclog.SetLogger(capnslog.NewPackageLogger("github.com/coreos/etcd/etcdserver", "v3rpc/grpc"))
}
示例10: Error
// 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 httptypes
import (
"encoding/json"
"net/http"
"github.com/coreos/pkg/capnslog"
)
var (
plog = capnslog.NewPackageLogger("github.com/coreos/etcd/etcdserver/etcdhttp", "httptypes")
)
type HTTPError struct {
Message string `json:"message"`
// Code is the HTTP status code
Code int `json:"-"`
}
func (e HTTPError) Error() string {
return e.Message
}
func (e HTTPError) WriteTo(w http.ResponseWriter) error {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(e.Code)
示例11: Accept
// 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 transport
import (
"errors"
"net"
"github.com/coreos/etcd/pkg/runtime"
"github.com/coreos/pkg/capnslog"
)
var plog = capnslog.NewPackageLogger("github.com/coreos/etcd/pkg", "transport")
type LimitedConnListener struct {
net.Listener
RuntimeFDLimit uint64
}
func (l *LimitedConnListener) Accept() (net.Conn, error) {
conn, err := l.Listener.Accept()
if err != nil {
return nil, err
}
n, err := runtime.FDUsage()
// Check whether fd number in use exceeds the set limit.
if err == nil && n >= l.RuntimeFDLimit {
示例12:
package torus
import (
"encoding/binary"
"errors"
"fmt"
"golang.org/x/net/context"
"github.com/coreos/pkg/capnslog"
"github.com/coreos/torus/models"
)
var BlockLog = capnslog.NewPackageLogger("github.com/coreos/torus", "blocklog")
type (
// VolumeID represents a unique identifier for a Volume.
VolumeID uint64
// IndexID represents a unique identifier for an Index.
IndexID uint64
// INodeID represents a unique identifier for an INode.
INodeID uint64
BlockType uint16
)
const (
TypeBlock BlockType = iota
TypeINode
示例13:
package compactor
import (
"sync"
"time"
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
"github.com/coreos/etcd/mvcc"
"github.com/coreos/pkg/capnslog"
"github.com/jonboulle/clockwork"
"golang.org/x/net/context"
)
var (
plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "compactor")
)
const (
checkCompactionInterval = 5 * time.Minute
)
type Compactable interface {
Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error)
}
type RevGetter interface {
Rev() int64
}
type Periodic struct {
示例14:
"os"
"sync"
"syscall"
"time"
"github.com/coreos/torus/block"
"github.com/coreos/pkg/capnslog"
"github.com/mdlayher/aoe"
"github.com/mdlayher/raw"
"golang.org/x/net/bpf"
"golang.org/x/net/context"
)
var (
clog = capnslog.NewPackageLogger("github.com/coreos/torus", "aoe")
broadcastAddr = net.HardwareAddr([]byte{0xff, 0xff, 0xff, 0xff, 0xff, 0xff})
)
type Server struct {
dfs *block.BlockVolume
dev Device
ctx context.Context
cancel context.CancelFunc
wg *sync.WaitGroup
major uint16
minor uint8
示例15:
"sync"
"time"
"github.com/coreos/etcd/etcdserver/stats"
"github.com/coreos/etcd/pkg/logutil"
"github.com/coreos/etcd/pkg/transport"
"github.com/coreos/etcd/pkg/types"
"github.com/coreos/etcd/raft"
"github.com/coreos/etcd/raft/raftpb"
"github.com/coreos/etcd/snap"
"github.com/coreos/pkg/capnslog"
"github.com/xiang90/probing"
"golang.org/x/net/context"
)
var plog = logutil.NewMergeLogger(capnslog.NewPackageLogger("github.com/coreos/etcd", "rafthttp"))
type Raft interface {
Process(ctx context.Context, m raftpb.Message) error
IsIDRemoved(id uint64) bool
ReportUnreachable(id uint64)
ReportSnapshot(id uint64, status raft.SnapshotStatus)
}
type Transporter interface {
// Start starts the given Transporter.
// Start MUST be called before calling other functions in the interface.
Start() error
// Handler returns the HTTP handler of the transporter.
// A transporter HTTP handler handles the HTTP requests
// from remote peers.