本文整理匯總了Golang中code/google/com/p/log4go.Logf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Logf函數的具體用法?Golang Logf怎麽用?Golang Logf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Logf函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RunTextCommand
func (ch *commandHandler) RunTextCommand(view *View, name string, args Args) error {
lvl := log4go.FINE
p := Prof.Enter("tc")
defer p.Exit()
t := time.Now()
if ch.log {
lvl = log4go.DEBUG
}
log4go.Logf(lvl, "Running text command: %s %v", name, args)
if c, ok := ch.TextCommands[name].(TextCommand); c != nil && ok {
if err := ch.init(c, args); err != nil && ch.verbose {
log4go.Debug("Command initialization failed: %s", err)
return err
} else if err := view.runCommand(c, name); err != nil {
log4go.Logf(lvl, "Command execution failed: %s", err)
return err
}
} else if w := view.Window(); w != nil {
if c, ok := ch.WindowCommands[name].(WindowCommand); c != nil && ok {
if err := w.runCommand(c, name); err != nil {
log4go.Logf(lvl, "Command execution failed: %s", err)
return err
}
}
}
log4go.Logf(lvl, "Ran text command: %s %s", name, time.Since(t))
return nil
}
示例2: inputthread
func (e *Editor) inputthread() {
pc := 0
var lastBindings KeyBindings
doinput := func(kp KeyPress) {
defer func() {
if r := recover(); r != nil {
log4go.Error("Panic in inputthread: %v\n%s", r, string(debug.Stack()))
if pc > 0 {
panic(r)
}
pc++
}
}()
p := Prof.Enter("hi")
defer p.Exit()
lvl := log4go.FINE
if e.loginput {
lvl++
}
log4go.Logf(lvl, "Key: %v", kp)
if lastBindings.keyOff == 0 {
lastBindings = e.keyBindings
}
try_again:
possible_actions := lastBindings.Filter(kp)
lastBindings = possible_actions
// TODO?
var (
wnd *Window
v *View
)
if wnd = e.ActiveWindow(); wnd != nil {
v = wnd.ActiveView()
}
if action := possible_actions.Action(v); action != nil {
p2 := Prof.Enter("hi.perform")
e.RunCommand(action.Command, action.Args)
p2.Exit()
} else if possible_actions.keyOff > 1 {
lastBindings = e.keyBindings
goto try_again
} else if kp.IsCharacter() {
p2 := Prof.Enter("hi.character")
log4go.Finest("kp: %v, pos: %v", kp, possible_actions)
if err := e.CommandHandler().RunTextCommand(v, "insert", Args{"characters": string(rune(kp.Key))}); err != nil {
log4go.Debug("Couldn't run textcommand: %s", err)
}
p2.Exit()
}
}
for kp := range e.keyInput {
doinput(kp)
}
}
示例3: RunWindowCommand
func (ch *commandHandler) RunWindowCommand(wnd *Window, name string, args Args) error {
lvl := log4go.FINE
p := Prof.Enter("wc")
defer p.Exit()
if ch.log {
lvl = log4go.DEBUG
}
log4go.Logf(lvl, "Running window command: %s %v", name, args)
t := time.Now()
if c := ch.WindowCommands[name]; c != nil {
if err := wnd.runCommand(c, name, args); err != nil {
log4go.Logf(lvl+1, "Command execution failed: %s", err)
} else {
log4go.Logf(lvl, "Ran Window command: %s %s", name, time.Since(t))
}
} else {
log4go.Logf(lvl, "No such window command: %s", name)
}
return nil
}