本文整理汇总了Golang中camlistore/org/pkg/client.Client.SetLogger方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.SetLogger方法的具体用法?Golang Client.SetLogger怎么用?Golang Client.SetLogger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类camlistore/org/pkg/client.Client
的用法示例。
在下文中一共展示了Client.SetLogger方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RunCommand
func (c *syncCmd) RunCommand(args []string) error {
if c.loop && !c.removeSrc {
return cmdmain.UsageError("Can't use --loop without --removesrc")
}
if c.verbose {
c.logger = log.New(os.Stderr, "", 0) // else nil
}
if c.all {
err := c.syncAll()
if err != nil {
return fmt.Errorf("sync all failed: %v", err)
}
return nil
}
if c.dest == "" {
return cmdmain.UsageError("No --dest specified.")
}
discl := c.discoClient()
discl.SetLogger(c.logger)
src, err := discl.BlobRoot()
if err != nil {
return fmt.Errorf("Failed to get blob source: %v", err)
}
sc := client.New(src)
sc.SetupAuth()
sc.SetLogger(c.logger)
dc := client.New(c.dest)
dc.SetupAuth()
dc.SetLogger(c.logger)
var tc *client.Client
if c.third != "" {
tc = client.New(c.third)
tc.SetupAuth()
tc.SetLogger(c.logger)
}
passNum := 0
for {
passNum++
stats, err := c.doPass(sc, dc, tc)
if c.verbose {
log.Printf("sync stats - pass: %d, blobs: %d, bytes %d\n", passNum, stats.BlobsCopied, stats.BytesCopied)
}
if err != nil {
return fmt.Errorf("sync failed: %v", err)
}
if !c.loop {
break
}
}
return nil
}
示例2: client
func (c *claimsCmd) client() *client.Client {
var cl *client.Client
if c.src == "" {
cl = client.NewOrFail()
} else {
cl = client.New(c.src)
}
cl.SetLogger(c.logger)
cl.SetHTTPClient(&http.Client{
Transport: cl.TransportForConfig(nil),
})
cl.SetupAuth()
return cl
}
示例3: discoClient
// discoClient returns a client initialized with a server
// based from --src or from the configuration file if --src
// is blank. The returned client can then be used to discover
// the blobRoot and syncHandlers.
func (c *syncCmd) discoClient() *client.Client {
var cl *client.Client
if c.src == "" {
cl = client.NewOrFail()
} else {
cl = client.New(c.src)
}
cl.SetLogger(c.logger)
cl.InsecureTLS = c.insecureTLS
cl.SetHTTPClient(&http.Client{
Transport: cl.TransportForConfig(nil),
})
cl.SetupAuth()
return cl
}
示例4: newUploader
func newUploader() *Uploader {
var cc *client.Client
var httpStats *httputil.StatsTransport
if d := *flagBlobDir; d != "" {
ss, err := dir.New(d)
if err != nil && d == "discard" {
ss = discardStorage{}
err = nil
}
if err != nil {
log.Fatalf("Error using dir %s as storage: %v", d, err)
}
cc = client.NewStorageClient(ss)
} else {
cc = client.NewOrFail()
proxy := http.ProxyFromEnvironment
if flagProxyLocal {
proxy = proxyFromEnvironment
}
tr := cc.TransportForConfig(
&client.TransportConfig{
Proxy: proxy,
Verbose: *flagHTTP,
})
httpStats, _ = tr.(*httputil.StatsTransport)
cc.SetHTTPClient(&http.Client{Transport: tr})
}
if *cmdmain.FlagVerbose {
cc.SetLogger(log.New(cmdmain.Stderr, "", log.LstdFlags))
} else {
cc.SetLogger(nil)
}
pwd, err := os.Getwd()
if err != nil {
log.Fatalf("os.Getwd: %v", err)
}
return &Uploader{
Client: cc,
transport: httpStats,
pwd: pwd,
fdGate: syncutil.NewGate(100), // gate things that waste fds, assuming a low system limit
}
}