• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang capnslog.NewPackageLogger函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog.NewPackageLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang NewPackageLogger函数的具体用法?Golang NewPackageLogger怎么用?Golang NewPackageLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewPackageLogger函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: writeError

	"time"

	etcdErr "github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/etcd/error"
	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/etcd/etcdserver"
	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/etcd/etcdserver/auth"
	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/etcd/etcdserver/etcdhttp/httptypes"
	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
)

const (
	// time to wait for a Watch request
	defaultWatchTimeout = time.Duration(math.MaxInt64)
)

var (
	plog      = capnslog.NewPackageLogger("github.com/coreos/etcd", "etcdhttp")
	errClosed = errors.New("etcdhttp: client closed connection")
)

// writeError logs and writes the given Error to the ResponseWriter
// If Error is an etcdErr, it is rendered to the ResponseWriter
// Otherwise, it is assumed to be an InternalServerError
func writeError(w http.ResponseWriter, err error) {
	if err == nil {
		return
	}
	switch e := err.(type) {
	case *etcdErr.Error:
		e.WriteTo(w)
	case *httptypes.HTTPError:
		e.WriteTo(w)
开发者ID:pwaller,项目名称:mantle,代码行数:31,代码来源:http.go


示例2: TarballName

	"io/ioutil"
	"net/http"
	"net/url"
	"os"
	"path"
	"path/filepath"

	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
)

const (
	urlHost = "storage.googleapis.com"
	urlPath = "/builds.developer.core-os.net/sdk"
)

var plog = capnslog.NewPackageLogger("github.com/coreos/mantle", "sdk")

func TarballName(version string) string {
	return fmt.Sprintf("coreos-sdk-%s-%s.tar.bz2", LocalArch(), version)
}

func TarballURL(version string) string {
	p := path.Join(urlPath, LocalArch(), version, TarballName(version))
	u := url.URL{Scheme: "https", Host: urlHost, Path: p}
	return u.String()
}

func DownloadFile(file, url string) error {
	plog.Infof("Downloading %s to %s", url, file)

	if err := os.MkdirAll(filepath.Dir(file), 0777); err != nil {
开发者ID:chancez,项目名称:mantle,代码行数:31,代码来源:download.go


示例3:

	"net/url"
	"path"
	"sort"
	"strconv"
	"strings"
	"time"

	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/etcd/client"
	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/etcd/pkg/types"
	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/jonboulle/clockwork"
	"github.com/coreos/mantle/Godeps/_workspace/src/golang.org/x/net/context"
)

var (
	plog = capnslog.NewPackageLogger("github.com/coreos/etcd", "discovery")

	ErrInvalidURL     = errors.New("discovery: invalid URL")
	ErrBadSizeKey     = errors.New("discovery: size key is bad")
	ErrSizeNotFound   = errors.New("discovery: size key not found")
	ErrTokenNotFound  = errors.New("discovery: token not found")
	ErrDuplicateID    = errors.New("discovery: found duplicate id")
	ErrFullCluster    = errors.New("discovery: cluster is full")
	ErrTooManyRetries = errors.New("discovery: too many retries")
)

var (
	// Number of retries discovery will attempt before giving up and erroring out.
	nRetries = uint(math.MaxUint32)
)
开发者ID:chancez,项目名称:mantle,代码行数:30,代码来源:discovery.go


示例4:

	"github.com/coreos/mantle/Godeps/_workspace/src/golang.org/x/net/context"
)

const (
	// StorePermsPrefix is the internal prefix of the storage layer dedicated to storing user data.
	StorePermsPrefix = "/2"

	// RootRoleName is the name of the ROOT role, with privileges to manage the cluster.
	RootRoleName = "root"

	// GuestRoleName is the name of the role that defines the privileges of an unauthenticated user.
	GuestRoleName = "guest"
)

var (
	plog = capnslog.NewPackageLogger("github.com/coreos/etcd/etcdserver", "auth")
)

var rootRole = Role{
	Role: RootRoleName,
	Permissions: Permissions{
		KV: RWPermission{
			Read:  []string{"*"},
			Write: []string{"*"},
		},
	},
}

var guestRole = Role{
	Role: GuestRoleName,
	Permissions: Permissions{
开发者ID:pwaller,项目名称:mantle,代码行数:31,代码来源:auth.go


示例5: IsDirWriteable

import (
	"io/ioutil"
	"os"
	"path"
	"sort"

	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
)

const (
	privateFileMode = 0600
)

var (
	plog = capnslog.NewPackageLogger("github.com/coreos/etcd/pkg", "fileutil")
)

// IsDirWriteable checks if dir is writable by writing and removing a file
// to dir. It returns nil if dir is writable.
func IsDirWriteable(dir string) error {
	f := path.Join(dir, ".touch")
	if err := ioutil.WriteFile(f, []byte(""), privateFileMode); err != nil {
		return err
	}
	return os.Remove(f)
}

// ReadDir returns the filenames in the given directory in sorted order.
func ReadDir(dirpath string) ([]string, error) {
	dir, err := os.Open(dirpath)
开发者ID:pwaller,项目名称:mantle,代码行数:30,代码来源:fileutil.go


示例6: init

// See the License for the specific language governing permissions and
// limitations under the License.

package etcd

import (
	"fmt"
	"time"

	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
	"github.com/coreos/mantle/kola/register"
	"github.com/coreos/mantle/platform"
	"github.com/coreos/mantle/util"
)

var plog = capnslog.NewPackageLogger("github.com/coreos/mantle", "kola/tests/etcd")

func init() {
	// test etcd discovery with 0.4.7
	register.Register(&register.Test{
		Run:         DiscoveryV1,
		Manual:      true,
		ClusterSize: 3,
		Name:        "coreos.etcd0.discovery",
		UserData: `#cloud-config
coreos:
  etcd:
    name: $name
    discovery: $discovery
    addr: $private_ipv4:2379
    peer-addr: $private_ipv4:2380`,
开发者ID:carriercomm,项目名称:mantle,代码行数:31,代码来源:discovery.go


示例7: init

// limitations under the License.

package ignition

import (
	"fmt"
	"strings"

	"github.com/coreos/mantle/kola/register"
	"github.com/coreos/mantle/platform"

	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
)

var (
	plog = capnslog.NewPackageLogger("github.com/coreos/mantle", "kola/tests/ignition")
)

func init() {
	// Set the hostname
	register.Register(&register.Test{
		Name:        "coreos.ignition.sethostname",
		Run:         setHostname,
		ClusterSize: 1,
		Platforms:   []string{"aws"},
		UserData: `{
		               "ignitionVersion": 1,
		               "storage": {
		                   "filesystems": [
		                       {
		                           "device": "/dev/disk/by-partlabel/ROOT",
开发者ID:carriercomm,项目名称:mantle,代码行数:31,代码来源:sethostname.go


示例8: init

// 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 main

import (
	"flag"
	oldlog "log"

	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
)

var logLevel = capnslog.INFO
var log = capnslog.NewPackageLogger("github.com/coreos/pkg/capnslog/cmd", "main")
var dlog = capnslog.NewPackageLogger("github.com/coreos/pkg/capnslog/cmd", "dolly")

func init() {
	flag.Var(&logLevel, "log-level", "Global log level.")
}

func main() {
	rl := capnslog.MustRepoLogger("github.com/coreos/pkg/capnslog/cmd")

	// We can parse the log level configs from the command line
	flag.Parse()
	if flag.NArg() > 1 {
		cfg, err := rl.ParseLogLevelConfig(flag.Arg(1))
		if err != nil {
			log.Fatal(err)
开发者ID:pwaller,项目名称:mantle,代码行数:31,代码来源:hello_dolly.go


示例9: init

func init() {
	raft.SetLogger(capnslog.NewPackageLogger("github.com/coreos/etcd", "raft"))
	expvar.Publish("raft.status", expvar.Func(func() interface{} { return raftStatus() }))
}
开发者ID:chancez,项目名称:mantle,代码行数:4,代码来源:raft.go


示例10: ServeHTTP

// 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 omaha

import (
	"encoding/xml"
	"io"
	"net/http"

	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
	"github.com/coreos/mantle/util"
)

var plog = capnslog.NewPackageLogger("github.com/coreos/mantle", "network/omaha")

type OmahaHandler struct {
	Updater
}

func (o *OmahaHandler) ServeHTTP(w http.ResponseWriter, httpReq *http.Request) {
	if httpReq.Method != "POST" {
		plog.Errorf("Unexpected HTTP method: %s", httpReq.Method)
		http.Error(w, "Expected a POST", http.StatusBadRequest)
		return
	}

	// A request over 1M in size is certainly bogus.
	var reader io.Reader
	reader = http.MaxBytesReader(w, httpReq.Body, 1024*1024)
开发者ID:carriercomm,项目名称:mantle,代码行数:31,代码来源:handler.go


示例11: MustMarshal

// 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.

package pbutil

import "github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"

var (
	plog = capnslog.NewPackageLogger("github.com/coreos/etcd/pkg", "flags")
)

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)
	}
开发者ID:chancez,项目名称:mantle,代码行数:31,代码来源:pbutil.go


示例12:

import (
	"bytes"
	"fmt"
	"net"
	"text/template"
	"time"

	"github.com/coreos/mantle/kola/register"
	"github.com/coreos/mantle/platform"
	"github.com/coreos/mantle/util"

	"github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
)

var (
	plog        = capnslog.NewPackageLogger("github.com/coreos/mantle", "kola/tests/flannel")
	flannelConf = template.Must(template.New("flannel-userdata").Parse(`#cloud-config
coreos:
  etcd2:
    name: $name
    discovery: $discovery
    advertise-client-urls: http://$private_ipv4:2379
    initial-advertise-peer-urls: http://$private_ipv4:2380
    listen-client-urls: http://0.0.0.0:2379,http://0.0.0.0:4001
    listen-peer-urls: http://$private_ipv4:2380,http://$private_ipv4:7001
  units:
    - name: etcd2.service
      command: start
    - name: flanneld.service
      drop-ins:
        - name: 50-network-config.conf
开发者ID:carriercomm,项目名称:mantle,代码行数:31,代码来源:flannel.go


示例13: 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/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
)

var (
	plog = capnslog.NewPackageLogger("github.com/coreos/etcd/etcdserver/etcdhttp", "httptypes")
)

type HTTPError struct {
	Message string `json:"message"`
	// HTTP return code
	Code int `json:"-"`
}

func (e HTTPError) Error() string {
	return e.Message
}

// TODO(xiangli): handle http write errors
func (e HTTPError) WriteTo(w http.ResponseWriter) {
	w.Header().Set("Content-Type", "application/json")
开发者ID:pwaller,项目名称:mantle,代码行数:31,代码来源:errors.go



注:本文中的github.com/coreos/mantle/Godeps/_workspace/src/github.com/coreos/pkg/capnslog.NewPackageLogger函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang proto.CompactTextString函数代码示例发布时间:2022-05-23
下一篇:
Golang raftpb.Message类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap