本文整理汇总了Golang中github.com/indyjo/bitwrk-common/bitwrk.Logger.Print方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Print方法的具体用法?Golang Logger.Print怎么用?Golang Logger.Print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/indyjo/bitwrk-common/bitwrk.Logger
的用法示例。
在下文中一共展示了Logger.Print方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: watchdog
// Closes resources upon exit of a function or when some condition no longer holds
// Arguments:
// - exitChan: Signals the watchdog to exit
// - closerChan: Signals the watchdog to add an io.Closer to the list of closers
// - f: Defines the OK condition. When false, all current closers are closed
func (t *Trade) watchdog(log bitwrk.Logger, exitChan <-chan bool, closerChan <-chan io.Closer, f func() bool) {
closers := make([]io.Closer, 0, 1)
for {
select {
case closer := <-closerChan:
closers = append(closers, closer)
case <-exitChan:
// Exit from watchdog if surrounding function has terminated
log.Print("Watchdog exiting by request")
return
default:
}
// Check if condition still holds
t.condition.L.Lock()
ok := f()
t.condition.L.Unlock()
if !ok {
log.Printf("Watchdog: closing %v channels", len(closers))
for _, c := range closers {
err := c.Close()
if err != nil {
log.Printf("Error closing channel: %v", err)
}
}
closers = closers[:0] // clear list of current closers
}
time.Sleep(250 * time.Millisecond)
}
}