本文整理汇总了Golang中github.com/limetext/lime-backend/lib/log.Debug函数的典型用法代码示例。如果您正苦于以下问题:Golang Debug函数的具体用法?Golang Debug怎么用?Golang Debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RunCommand
func (e *Editor) RunCommand(name string, args Args) {
// TODO?
var (
wnd *Window
v *View
)
if wnd = e.ActiveWindow(); wnd != nil {
v = wnd.ActiveView()
}
// TODO: what's the command precedence?
if c := e.cmdHandler.TextCommands[name]; c != nil {
if err := e.CommandHandler().RunTextCommand(v, name, args); err != nil {
log.Debug("Couldn't run textcommand: %s", err)
}
} else if c := e.cmdHandler.WindowCommands[name]; c != nil {
if err := e.CommandHandler().RunWindowCommand(wnd, name, args); err != nil {
log.Debug("Couldn't run windowcommand: %s", err)
}
} else if c := e.cmdHandler.ApplicationCommands[name]; c != nil {
if err := e.CommandHandler().RunApplicationCommand(name, args); err != nil {
log.Debug("Couldn't run applicationcommand: %s", err)
}
} else {
log.Debug("Couldn't find command to run")
}
}
示例2: call
// Execute the InitEvent.
func (ie *InitEvent) call() {
log.Debug("OnInit callbacks executing")
defer log.Debug("OnInit callbacks finished")
for _, ev := range *ie {
ev()
}
}
示例3: setColorMode
func setColorMode() {
var (
mode256 bool
pal = make([]termbox.RGB, 0, 256)
)
if err := termbox.SetColorMode(termbox.ColorMode256); err != nil {
log.Errorf("Unable to use 256 color mode: %s", err)
} else {
log.Debug("Using 256 color mode")
mode256 = true
}
if !mode256 {
pal = pal[:10] // Not correct, but whatever
pal[termbox.ColorBlack] = termbox.RGB{R: 0, G: 0, B: 0}
pal[termbox.ColorWhite] = termbox.RGB{R: 255, G: 255, B: 255}
pal[termbox.ColorRed] = termbox.RGB{R: 255, G: 0, B: 0}
pal[termbox.ColorGreen] = termbox.RGB{R: 0, G: 255, B: 0}
pal[termbox.ColorBlue] = termbox.RGB{R: 0, G: 0, B: 255}
pal[termbox.ColorMagenta] = termbox.RGB{R: 255, G: 0, B: 255}
pal[termbox.ColorYellow] = termbox.RGB{R: 255, G: 255, B: 0}
pal[termbox.ColorCyan] = termbox.RGB{R: 0, G: 255, B: 255}
diff := func(i, j byte) int {
v := int(i) - int(j)
if v < 0 {
return -v
}
return v
}
palLut = func(col textmate.Color) termbox.Attribute {
mindist := 10000000
mini := 0
for i, c := range pal {
if dist := diff(c.R, col.R) + diff(c.G, col.G) + diff(c.B, col.B); dist < mindist {
mindist = dist
mini = i
}
}
return termbox.Attribute(mini)
}
} else {
palLut = func(col textmate.Color) termbox.Attribute {
tc := termbox.RGB{R: col.R, G: col.G, B: col.B}
for i, c := range pal {
if c == tc {
return termbox.Attribute(i)
}
}
l := len(pal)
log.Debug("Adding colour: %d %+v %+v", l, col, tc)
pal = append(pal, tc)
termbox.SetColorPalette(pal)
return termbox.Attribute(l)
}
}
}
示例4: loop
func (t *tbfe) loop() {
timechan := make(chan bool, 0)
// Only set up the timers if we should actually blink the cursor
// This should somehow be changable on an OnSettingsChanged callback
if p, _ := t.editor.Settings().Get("caret_blink", true).(bool); p {
duration := time.Second / 2
if p, ok := t.editor.Settings().Get("caret_blink_phase", 1.0).(float64); ok {
duration = time.Duration(float64(time.Second)*p) / 2
}
timer := time.NewTimer(duration)
defer func() {
timer.Stop()
close(timechan)
}()
go func() {
for range timer.C {
timechan <- true
timer.Reset(duration)
}
}()
}
// Due to termbox still running, we can't close evchan
evchan := make(chan termbox.Event, 32)
go func() {
for {
evchan <- termbox.PollEvent()
}
}()
for {
p := util.Prof.Enter("mainloop")
select {
case ev := <-evchan:
mp := util.Prof.Enter("evchan")
switch ev.Type {
case termbox.EventError:
log.Debug("error occured")
return
case termbox.EventResize:
t.handleResize(ev.Height, ev.Width, false)
case termbox.EventKey:
t.handleInput(ev)
blink = false
}
mp.Exit()
case <-timechan:
blink = !blink
t.render()
case <-t.shutdown:
return
}
p.Exit()
}
}
示例5: onInit
func onInit() {
l := py.NewLock()
defer l.Unlock()
m, err := py.Import("sublime_plugin")
if err != nil {
panic(err)
}
sys, err := py.Import("sys")
if err != nil {
log.Debug(err)
} else {
defer sys.Decref()
}
if watcher, err = watch.NewWatcher(); err != nil {
log.Errorf("Couldn't create watcher: %s", err)
}
// TODO: add all plugins after supporting all commands
// plugins := packages.ScanPlugins(backend.LIME_PACKAGES_PATH, ".py")
// for _, p := range plugins {
// newPlugin(p, m)
// }
newPlugin(packages.NewPlugin(path.Join(backend.LIME_PACKAGES_PATH, "Vintageous"), ".py"), m)
go watcher.Observe()
}
示例6: sublime_set_timeout
func sublime_set_timeout(tu *py.Tuple, kwargs *py.Dict) (py.Object, error) {
var (
pyarg py.Object
)
if tu.Size() != 2 {
return nil, fmt.Errorf("Unexpected argument count: %d", tu.Size())
}
if i, err := tu.GetItem(0); err != nil {
return nil, err
} else {
pyarg = i
}
if i, err := tu.GetItem(1); err != nil {
return nil, err
} else if v, err := fromPython(i); err != nil {
return nil, err
} else if v2, ok := v.(int); !ok {
return nil, fmt.Errorf("Expected int not %s", i.Type())
} else {
pyarg.Incref()
go func() {
time.Sleep(time.Millisecond * time.Duration(v2))
l := py.NewLock()
defer l.Unlock()
defer pyarg.Decref()
if ret, err := pyarg.Base().CallFunctionObjArgs(); err != nil {
log.Debug("Error in callback: %v", err)
} else {
ret.Decref()
}
}()
}
return toPython(nil)
}
示例7: key
// key HandleFunc for the http /key endpoint. This only happens if the client
// doesn't support websockets.
func (t *tbfe) key(w http.ResponseWriter, req *http.Request) {
log.Debug("key: %s", req)
kc := req.FormValue("keyCode")
var kp keys.KeyPress
v, _ := strconv.ParseInt(kc, 10, 32)
if req.FormValue("altKey") == "true" {
kp.Alt = true
}
if req.FormValue("ctrlKey") == "true" {
kp.Ctrl = true
}
if req.FormValue("metaKey") == "true" {
kp.Super = true
}
if req.FormValue("shiftKey") == "true" {
kp.Shift = true
}
if !kp.Shift {
v = int64(unicode.ToLower(rune(v)))
}
kp.Key = keys.Key(v)
kp.Text = string(v)
backend.GetEditor().HandleInput(kp)
}
示例8: RunTextCommand
func (ch *commandHandler) RunTextCommand(view *View, name string, args Args) error {
lvl := log.FINE
p := Prof.Enter("tc")
defer p.Exit()
t := time.Now()
if ch.log {
lvl = log.DEBUG
}
log.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 {
log.Debug("Command initialization failed: %s", err)
return err
} else if err := view.runCommand(c, name); err != nil {
log.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 {
log.Logf(lvl, "Command execution failed: %s", err)
return err
}
}
}
log.Logf(lvl, "Ran text command: %s %s", name, time.Since(t))
return nil
}
示例9: main
func main() {
flag.Parse()
log.AddFilter("file", log.FINEST, log.NewFileLogWriter("debug.log", *rotateLog))
defer func() {
py.NewLock()
py.Finalize()
}()
if err := termbox.Init(); err != nil {
log.Close(err)
return
}
defer func() {
termbox.Close()
log.Debug(util.Prof)
if err := recover(); err != nil {
log.Critical(err)
panic(err)
}
}()
t := createFrontend()
go t.renderthread()
go t.editor.Init()
t.loop()
}
示例10: view
func (t *tbfe) view(w http.ResponseWriter, req *http.Request) {
log.Debug("view: %s", req)
if t.dirty {
t.dirty = false
t.render(w)
} else {
w.WriteHeader(404)
}
}
示例11: ServeHTTP
func (t *tbfe) ServeHTTP(w http.ResponseWriter, req *http.Request) {
s := time.Now()
w.Header().Set("Content-Type", "text/html")
log.Debug("Serving client: %s", req)
c := scheme.Spice(&render.ViewRegions{})
html, err := ioutil.ReadFile("index.html")
if err != nil {
w.WriteHeader(404)
panic(err)
}
r := strings.NewReplacer("{{foregroundColor}}", htmlcol(c.Foreground), "{{backgroundColor}}", htmlcol(c.Background))
r.WriteString(w, string(html))
log.Debug("Done serving client: %s", time.Since(s))
}
示例12: RunApplicationCommand
func (ch *commandHandler) RunApplicationCommand(name string, args Args) error {
p := Prof.Enter("ac")
defer p.Exit()
if ch.log {
log.Info("Running application command: %s %v", name, args)
} else {
log.Fine("Running application command: %s %v", name, args)
}
if c, ok := ch.ApplicationCommands[name].(ApplicationCommand); c != nil && ok {
if err := ch.init(c, args); err != nil && ch.verbose {
log.Debug("Command initialization failed: %s", err)
return err
} else if err := c.Run(); err != nil && ch.verbose {
log.Debug("Command execution failed: %s", err)
return err
}
}
return nil
}
示例13: Parse
func (lp *LanguageParser) Parse() (*parser.Node, error) {
sdata := string(lp.data)
rn := parser.Node{P: lp, Name: lp.l.ScopeName}
defer func() {
if r := recover(); r != nil {
log.Errorf("Panic during parse: %v\n", r)
log.Debug("%v", rn)
}
}()
iter := maxiter
for i := 0; i < len(sdata) && iter > 0; iter-- {
pat, ret := lp.l.RootPattern.Cache(sdata, i)
nl := strings.IndexAny(sdata[i:], "\n\r")
if nl != -1 {
nl += i
}
if ret == nil {
break
} else if nl > 0 && nl <= ret[0] {
i = nl
for i < len(sdata) && (sdata[i] == '\n' || sdata[i] == '\r') {
i++
}
} else {
n := pat.CreateNode(sdata, i, lp, ret)
rn.Append(n)
i = n.Range.B
}
}
rn.UpdateRange()
if len(sdata) != 0 {
lut := make([]int, len(sdata)+1)
j := 0
for i := range sdata {
lut[i] = j
j++
}
lut[len(sdata)] = len(lp.data)
lp.patch(lut, &rn)
}
if iter == 0 {
panic("reached maximum number of iterations")
}
return &rn, nil
}
示例14: Watch
func (w *Watcher) Watch(name string, cb interface{}) error {
log.Finest("Watch(%s)", name)
fi, err := os.Stat(name)
isDir := err == nil && fi.IsDir()
// If the file doesn't exist currently we will add watcher for file
// directory and look for create event inside the directory
if os.IsNotExist(err) {
log.Fine("%s doesn't exist, Watching parent directory", name)
if err := w.Watch(filepath.Dir(name), nil); err != nil {
return err
}
}
w.lock.Lock()
defer w.lock.Unlock()
if err := w.add(name, cb); err != nil {
if !isDir {
return err
}
if exist(w.dirs, name) {
log.Debug("%s is watched already", name)
return nil
}
}
// If exists in watchers we are already watching the path
// Or
// If the file is under one of watched dirs
//
// no need to create watcher
if exist(w.watchers, name) || (!isDir && exist(w.dirs, filepath.Dir(name))) {
return nil
}
if err := w.watch(name); err != nil {
return err
}
if isDir {
w.flushDir(name)
}
return nil
}
示例15: Show
func (q *qmlDialog) Show(msg, icon string) (ret int) {
src := `import QtQuick 2.2
import QtQuick.Dialogs 1.1
Item {MessageDialog {
objectName: "realDialog"
id: messageDialog
title: "May I have your attention please"
text: "` + msg + `"
icon: ` + icon + `
standardButtons: StandardButton.Ok | StandardButton.Cancel
Component.onCompleted: visible = true
}}`
engine := qml.NewEngine()
engine.Context().SetVar("q", q)
component, err := engine.LoadString("dialog.qml", src)
if err != nil {
log.Error("Unable to instanciate dialog: %s", err)
return 0
}
var wg sync.WaitGroup
wg.Add(1)
obj := component.Create(nil)
obj = obj.ObjectByName("realDialog")
obj.On("accepted", func() {
ret = 1
wg.Done()
})
obj.On("rejected", func() {
ret = 0
wg.Done()
})
wg.Wait()
engine.Destroy()
log.Debug("returning %d", ret)
return
}