本文整理汇总了Golang中github.com/keybase/client/go/logger.Logger类的典型用法代码示例。如果您正苦于以下问题:Golang Logger类的具体用法?Golang Logger怎么用?Golang Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: FilterTLFEarlyExitError
// FilterTLFEarlyExitError decides whether an error received while
// trying to create a TLF should result in showing the user an empty
// folder (exitEarly == true), or not.
func FilterTLFEarlyExitError(ctx context.Context, err error, log logger.Logger, name libkbfs.CanonicalTlfName) (
exitEarly bool, retErr error) {
switch err := err.(type) {
case nil:
// No error.
return false, nil
case libkbfs.WriteAccessError:
// No permission to create TLF, so pretend it's still
// empty.
//
// In theory, we need to invalidate this once the TLF
// is created, but in practice, the Linux kernel
// doesn't cache readdir results, and probably not
// OSXFUSE either.
log.CDebugf(ctx,
"No permission to write to %s, so pretending it's empty",
name)
return true, nil
case libkbfs.MDServerErrorWriteAccess:
// Same as above; cannot fallthrough in type switch
log.CDebugf(ctx,
"No permission to write to %s, so pretending it's empty",
name)
return true, nil
default:
// Some other error.
return true, err
}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:35,代码来源:tlf.go
示例2: tail
func tail(Log logger.Logger, filename string, numLines int) string {
if filename == "" {
return ""
}
f, err := os.Open(filename)
if err != nil {
Log.Warning("error opening log %q: %s", filename, err)
return ""
}
b := rogReverse.NewScanner(f)
b.Split(bufio.ScanLines)
var lines []string
for b.Scan() {
lines = append(lines, b.Text())
if len(lines) == numLines {
break
}
}
for left, right := 0, len(lines)-1; left < right; left, right = left+1, right-1 {
lines[left], lines[right] = lines[right], lines[left]
}
return strings.Join(lines, "\n")
}
开发者ID:qbit,项目名称:client,代码行数:27,代码来源:log_send.go
示例3: NewUpdater
func NewUpdater(options keybase1.UpdateOptions, source sources.UpdateSource, config Config, log logger.Logger) *Updater {
log.Debug("New updater with options: %#v", options)
return &Updater{
options: options,
source: source,
config: config,
log: log,
}
}
开发者ID:jacobhaven,项目名称:client,代码行数:9,代码来源:updater.go
示例4: ShowStatus
// ShowStatus shows status info for a service
func ShowStatus(label string, log logger.Logger) error {
service := NewService(label)
service.SetLogger(log)
status, err := service.LoadStatus()
if err != nil {
return err
}
if status != nil {
log.Info("%s", status.Description())
} else {
log.Info("No service found with label: %s", label)
}
return nil
}
开发者ID:mark-adams,项目名称:client,代码行数:15,代码来源:launchd.go
示例5: WaitForServiceInfoFile
// WaitForServiceInfoFile tries to wait for a service info file, which should be
// written on successful service startup.
func WaitForServiceInfoFile(path string, label string, pid string, maxAttempts int, wait time.Duration, reason string, log logger.Logger) (*ServiceInfo, error) {
if pid == "" {
return nil, fmt.Errorf("No pid to wait for")
}
lookForServiceInfo := func() (*ServiceInfo, error) {
if _, ferr := os.Stat(path); os.IsNotExist(ferr) {
return nil, nil
}
dat, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
var serviceInfo ServiceInfo
err = json.Unmarshal(dat, &serviceInfo)
if err != nil {
return nil, err
}
// Make sure the info file is the pid we are waiting for, otherwise it is
// still starting up.
if pid != fmt.Sprintf("%d", serviceInfo.Pid) {
return nil, nil
}
// PIDs match, the service has started up
return &serviceInfo, nil
}
attempt := 1
serviceInfo, lookErr := lookForServiceInfo()
for attempt < maxAttempts && serviceInfo == nil {
attempt++
log.Debug("Waiting for service info file...")
time.Sleep(wait)
serviceInfo, lookErr = lookForServiceInfo()
}
// If no service info was found, let's return an error
if serviceInfo == nil {
if lookErr == nil {
lookErr = fmt.Errorf("%s isn't running (expecting pid=%s)", label, pid)
}
return nil, lookErr
}
// We succeeded in finding service info
log.Debug("Found service info: %#v", *serviceInfo)
return serviceInfo, nil
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:52,代码来源:service_info.go
示例6: ctxWithRandomID
func ctxWithRandomID(ctx context.Context, tagKey interface{},
tagName string, log logger.Logger) context.Context {
// Tag each request with a unique ID
logTags := make(logger.CtxLogTags)
logTags[tagKey] = tagName
newCtx := logger.NewContextWithLogTags(ctx, logTags)
id, err := MakeRandomRequestID()
if err != nil {
if log != nil {
log.Warning("Couldn't generate a random request ID: %v", err)
}
} else {
newCtx = context.WithValue(newCtx, tagKey, id)
}
return newCtx
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:16,代码来源:util.go
示例7: NewContextWithOpID
// NewContextWithOpID adds a unique ID to this context, identifying
// a particular request.
func NewContextWithOpID(ctx context.Context,
log logger.Logger) context.Context {
if runtime.GOOS == "darwin" {
// Timeout operations before they hit the osxfuse time limit,
// so we don't hose the entire mount. The timeout is 60
// seconds, but it looks like sometimes it tries multiple
// attempts within that 60 seconds, so let's go a little under
// 60/3 to be safe.
ctx, _ = context.WithTimeout(ctx, 19*time.Second)
}
id, err := libkbfs.MakeRandomRequestID()
if err != nil {
log.Errorf("Couldn't make request ID: %v", err)
return ctx
}
return context.WithValue(ctx, CtxIDKey, id)
}
开发者ID:gozes,项目名称:kbfs-beta,代码行数:19,代码来源:common.go
示例8: loop
func (r *RemoteStatus) loop(ctx context.Context, log logger.Logger, config libkbfs.Config) {
for {
tctx, cancel := context.WithTimeout(ctx, 1*time.Second)
st, ch, err := config.KBFSOps().Status(tctx)
// No deferring inside loops, and no panics either here.
cancel()
if err != nil {
log.Warning("KBFS Status failed: %v", err)
}
r.update(st)
// Block on the channel or shutdown.
select {
case <-ctx.Done():
return
case <-ch:
}
}
}
开发者ID:keybase,项目名称:kbfs-beta,代码行数:18,代码来源:remote_status.go
示例9: makeBlockServer
func makeBlockServer(config Config, serverInMemory bool, serverRootDir, bserverAddr string, log logger.Logger) (
BlockServer, error) {
if serverInMemory {
// local in-memory block server
return NewBlockServerMemory(config)
}
if len(serverRootDir) > 0 {
// local persistent block server
blockPath := filepath.Join(serverRootDir, "kbfs_block")
return NewBlockServerLocal(config, blockPath)
}
if len(bserverAddr) == 0 {
return nil, errors.New("Empty block server address")
}
log.Debug("Using remote bserver %s", bserverAddr)
return NewBlockServerRemote(config, bserverAddr), nil
}
开发者ID:gozes,项目名称:kbfs-beta,代码行数:20,代码来源:init.go
示例10: ShowServices
// ShowServices outputs keybase service info.
func ShowServices(filters []string, name string, log logger.Logger) (err error) {
services, err := ListServices(filters)
if err != nil {
return
}
if len(services) > 0 {
log.Info("%s %s:", name, libkb.Pluralize(len(services), "service", "services", false))
for _, service := range services {
log.Info(service.StatusDescription())
}
log.Info("")
} else {
log.Info("No %s services.\n", name)
}
return
}
开发者ID:moul,项目名称:client,代码行数:17,代码来源:launchd.go
示例11: checkSystemUser
func checkSystemUser(log logger.Logger) {
if isAdminUser, match, _ := libkb.IsSystemAdminUser(); isAdminUser {
log.Errorf("Oops, you are trying to run as an admin user (%s). This isn't supported.", match)
os.Exit(int(keybase1.ExitCode_NOTOK))
}
}
开发者ID:mark-adams,项目名称:client,代码行数:6,代码来源:main.go
示例12: warnNonProd
func warnNonProd(log logger.Logger, e *libkb.Env) {
mode := e.GetRunMode()
if mode != libkb.ProductionRunMode {
log.Warning("Running in %s mode", mode)
}
}
开发者ID:mark-adams,项目名称:client,代码行数:6,代码来源:main.go
示例13: FindPinentry
func FindPinentry(log logger.Logger) (string, error) {
if !HasWindows() {
return "", fmt.Errorf("Can't spawn gui window, not using pinentry")
}
bins := []string{
// If you install MacTools you'll wind up with this pinentry
"/usr/local/MacGPG2/libexec/pinentry-mac.app/Contents/MacOS/pinentry-mac",
}
extraPaths := []string{}
log.Debug("+ FindPinentry()")
cmds := []string{
"pinentry-gtk-2",
"pinentry-qt4",
"pinentry",
}
checkFull := func(s string) bool {
log.Debug("| Check fullpath %s", s)
found := (canExec(s) == nil)
if found {
log.Debug("- Found: %s", s)
}
return found
}
for _, b := range bins {
if checkFull(b) {
return b, nil
}
}
path := os.Getenv("PATH")
for _, c := range cmds {
log.Debug("| Looking for %s in standard PATH %s", c, path)
fullc, err := exec.LookPath(c)
if err == nil {
log.Debug("- Found %s", fullc)
return fullc, nil
}
}
for _, ep := range extraPaths {
for _, c := range cmds {
full := filepath.Join(ep, c)
if checkFull(full) {
return full, nil
}
}
}
log.Debug("- FindPinentry: none found")
return "", fmt.Errorf("No pinentry found, checked a bunch of different places")
}
开发者ID:polluks,项目名称:client,代码行数:56,代码来源:pinentry_nix.go
示例14: FindPinentry
func FindPinentry(log logger.Logger) (string, error) {
// // If you install GPG you'll wind up with this pinentry
// C:\Program Files (x86)\GNU\GnuPG\pinentry-gtk-2.exe
// C:\Program Files (x86)\GNU\GnuPG\pinentry-qt4.exe
// C:\Program Files (x86)\GNU\GnuPG\pinentry-w32.exe
// C:\Program Files (x86)\GNU\GnuPG\pinentry.exe
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Wow6432Node\GNU\GnuPG`, registry.QUERY_VALUE)
if err != nil {
k, err = registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\GNU\GnuPG`, registry.QUERY_VALUE)
}
if err != nil {
log.Debug("- FindPinentry: can't open registry")
}
defer k.Close()
installDir, _, err := k.GetStringValue("Install Directory")
if err != nil {
log.Debug("- FindPinentry: can't get string from registry")
}
extraPaths := []string{}
log.Debug("+ FindPinentry()")
cmds := []string{
"pinentry-gtk-2.exe",
"pinentry-qt4.exe",
"pinentry-w32.exe",
"pinentry.exe",
}
// First, look where the registry points
for _, c := range cmds {
full := filepath.Join(installDir, c)
log.Debug("| (registry) Looking for %s", full)
_, err := exec.LookPath(full)
if err == nil {
return full, nil
}
}
// Look in program files, just in case
extraPaths = append(extraPaths, os.Getenv("ProgramFiles"))
extraPaths = append(extraPaths, os.Getenv("ProgramFiles(x86)"))
for _, ep := range extraPaths {
for _, c := range cmds {
full := filepath.Join(ep, "GNU", "GnuPG", c)
log.Debug("| Looking for %s", full)
_, err := exec.LookPath(full)
if err == nil {
return full, nil
}
}
}
log.Debug("- FindPinentry: none found")
return "", fmt.Errorf("No pinentry found, checked a bunch of different places")
}
开发者ID:mark-adams,项目名称:client,代码行数:61,代码来源:pinentry_windows.go
示例15: Trace
func Trace(log logger.Logger, msg string, f func() error) func() {
log.Debug("+ %s", msg)
return func() { log.Debug("- %s -> %s", msg, ErrToOk(f())) }
}
开发者ID:jacobhaven,项目名称:client,代码行数:4,代码来源:util.go
注:本文中的github.com/keybase/client/go/logger.Logger类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论