本文整理汇总了Golang中github.com/op/go-logging.Logger.Error方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Error方法的具体用法?Golang Logger.Error怎么用?Golang Logger.Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/op/go-logging.Logger
的用法示例。
在下文中一共展示了Logger.Error方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewForwardInput
func NewForwardInput(logger *logging.Logger, bind string, port Port) (*ForwardInput, error) {
_codec := codec.MsgpackHandle{}
_codec.MapType = reflect.TypeOf(map[string]interface{}(nil))
_codec.RawToString = false
addr, err := net.ResolveTCPAddr("tcp", bind)
if err != nil {
logger.Error("%s", err.Error())
return nil, err
}
listener, err := net.ListenTCP("tcp", addr)
if err != nil {
logger.Error("%s", err.Error())
return nil, err
}
return &ForwardInput{
port: port,
logger: logger,
bind: bind,
listener: listener,
codec: &_codec,
clients: make(map[*net.TCPConn]*forwardClient),
clientsMtx: sync.Mutex{},
entries: 0,
wg: sync.WaitGroup{},
acceptChan: make(chan *net.TCPConn),
shutdownChan: make(chan struct{}),
isShuttingDown: uintptr(0),
}, nil
}
示例2: Diff
// Execute a `git status a b`
func Diff(log *log.Logger, a, b string) (string, error) {
args := []string{"diff",
a,
b,
}
if msg, err := util.Exec(log, cmdName, args...); err != nil {
if log != nil {
log.Error(msg)
} else {
fmt.Printf("%s\n", msg)
}
return "", maskAny(err)
} else {
return strings.TrimSpace(msg), nil
}
}
示例3: Status
// Execute a `git status`
func Status(log *log.Logger, porcelain bool) (string, error) {
args := []string{"status"}
if porcelain {
args = append(args, "--porcelain")
}
if msg, err := util.Exec(log, cmdName, args...); err != nil {
if log != nil {
log.Error(msg)
} else {
fmt.Printf("%s\n", msg)
}
return "", maskAny(err)
} else {
return strings.TrimSpace(msg), nil
}
}
示例4: initGit
func initGit(log *log.Logger, projectDir string) error {
path := filepath.Join(projectDir, gitDirPath)
if info, err := os.Stat(path); os.IsNotExist(err) {
if err := util.ExecuteInDir(projectDir, func() error {
output, err := util.Exec(log, "git", "init")
if err != nil {
log.Error(output)
return maskAny(err)
}
return nil
}); err != nil {
return maskAny(err)
}
} else if err != nil {
return maskAny(err)
} else if !info.IsDir() {
return maskAny(fmt.Errorf("%s must be a directory", path))
} else {
log.Debugf("Git already initialized in %s", projectDir)
}
return nil
}