当前位置: 首页>>代码示例>>Golang>>正文


Golang log.Debugf函数代码示例

本文整理汇总了Golang中gnd/la/log.Debugf函数的典型用法代码示例。如果您正苦于以下问题:Golang Debugf函数的具体用法?Golang Debugf怎么用?Golang Debugf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了Debugf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: gaeDevCommand

func gaeDevCommand(_ *command.Args, opts *gaeDevOptions) error {
	log.Debugf("starting App Engine development server - press Control+C to stop")
	var buildArgs []string
	resources, err := makeAppAssets(buildArgs)
	if err != nil {
		return err
	}
	go watchAppResources(buildArgs, resources)
	serveCmd, err := startServe(buildArgs, opts)
	if err != nil {
		return err
	}
	errCh := make(chan error, 1)
	go func() {
		errCh <- serveCmd.Wait()
	}()
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, os.Interrupt)
	select {
	case <-ch:
		log.Debugf("exiting")
		<-errCh
		log.Debugf("exited")
	case err := <-errCh:
		return err
	}
	return nil
}
开发者ID:rainycape,项目名称:gondola,代码行数:28,代码来源:gae.go

示例2: replaceExtendTag

func (t *Template) replaceExtendTag(name string, treeMap map[string]*parse.Tree, from string) error {
	var err error
	hasExtend := false
	var loc string
	for _, v := range treeMap {
		templateutil.WalkTree(v, func(n, p parse.Node) {
			if err != nil {
				return
			}
			if templateutil.IsPseudoFunction(n, "extend") {
				if hasExtend {
					loc2, _ := v.ErrorContext(n)
					err = fmt.Errorf("multiple {{ extend }} tags in %q, %s and %s", name, loc, loc2)
					return
				}
				hasExtend = true
				loc, _ = v.ErrorContext(n)
				var repl parse.Node
				if from == "" {
					// empty
					log.Debugf("removing {{ extend }} from %q", name)
					repl = &parse.TextNode{
						NodeType: parse.NodeText,
						Pos:      n.Position(),
					}
				} else {
					log.Debugf("extending %q at %s with %q", name, loc, from)
					repl = templateutil.TemplateNode(from, n.Position())
				}
				err = templateutil.ReplaceNode(n, p, repl)
			}
		})
	}
	return err
}
开发者ID:rainycape,项目名称:gondola,代码行数:35,代码来源:template.go

示例3: sendCommand

func sendCommand(serverAddr string, args []string) (bool, error) {
	scheme, addr, err := parseServerAddr(serverAddr)
	if err != nil {
		return false, err
	}
	conn, err := net.Dial(scheme, addr)
	if err != nil {
		return false, err
	}
	defer conn.Close()
	if err := encodeArgs(conn, args); err != nil {
		return false, err
	}
	log.Debugf("sent command %s", args)
	closed := false
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, os.Interrupt)
	defer signal.Stop(ch)
	done := make(chan struct{}, 1)
	defer func() {
		done <- struct{}{}
	}()
	go func() {
		select {
		case <-ch:
			closed = true
			conn.Close()
		case <-done:
		}
	}()
	ok := true
	for {
		r, s, err := decodeResponse(conn)
		if err != nil {
			if closed {
				return ok, nil
			}
			return ok, err
		}
		log.Debugf("received response %d", r)
		switch r {
		case respEnd:
			return ok, nil
		case respOk:
			fmt.Print(s)
		case respErr:
			ok = false
			fmt.Fprint(os.Stderr, s)
		default:
			return false, fmt.Errorf("invalid response type %d", r)
		}
	}
	return ok, nil
}
开发者ID:rainycape,项目名称:governator,代码行数:54,代码来源:client.go

示例4: importAssets

func (app *App) importAssets(included *includedApp) error {
	im := included.app.assetsManager
	if !app.shouldImportAssets() {
		im.SetPrefix(included.prefix + im.Prefix())
		return nil
	}
	m := app.assetsManager
	prefix := strings.ToLower(included.name)
	renames := make(map[string]string)
	err := vfs.Walk(im.VFS(), "/", func(fs vfs.VFS, p string, info os.FileInfo, err error) error {
		if err != nil || info.IsDir() {
			return err
		}
		if p != "" && p[0] == '/' {
			p = p[1:]
		}
		log.Debugf("will import asset %v from app %s", p, included.name)
		src, err := im.Load(p)
		if err != nil {
			return err
		}
		defer src.Close()
		seeker, err := assets.Seeker(src)
		if err != nil {
			return err
		}
		sum := hashutil.Fnv32a(seeker)
		nonExt := p[:len(p)-len(path.Ext(p))]
		dest := path.Join(prefix, nonExt+".gen."+sum+path.Ext(p))
		renames[p] = dest
		log.Debugf("importing asset %q as %q", p, dest)
		if m.Has(dest) {
			return nil
		}
		f, err := m.Create(dest, true)
		if err != nil {
			return err
		}
		defer f.Close()
		if _, err := seeker.Seek(0, os.SEEK_SET); err != nil {
			return err
		}
		if _, err := io.Copy(f, seeker); err != nil {
			return err
		}
		return nil
	})
	if err != nil {
		return err
	}
	included.renames = renames
	return nil
}
开发者ID:rainycape,项目名称:gondola,代码行数:53,代码来源:app.go

示例5: extractGoType

func extractGoType(messages messageMap, fset *token.FileSet, f *ast.File, typ string) error {
	// for castings
	calls, err := astutil.Calls(fset, f, typ)
	if err != nil {
		return err
	}
	for _, c := range calls {
		if len(c.Args) > 0 {
			lit, pos := astutil.StringLiteral(fset, c.Args[0])
			if pos == nil {
				p := fset.Position(c.Pos())
				log.Debugf("Skipping cast to %s (%v) - not a literal", typ, p)
				continue
			}
			comment := comments(fset, f, pos)
			if err := messages.AddString(&astutil.String{Value: lit, Position: pos}, comment); err != nil {
				return err
			}
		}
	}
	strings, err := astutil.Strings(fset, f, typ)
	if err != nil {
		return err
	}
	for _, s := range strings {
		comment := comments(fset, f, s.Position)
		if err := messages.AddString(s, comment); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:rainycape,项目名称:gondola,代码行数:32,代码来源:extract.go

示例6: extractGoMessages

func extractGoMessages(messages messageMap, path string, opts *ExtractOptions) error {
	log.Debugf("Extracting messages from Go file %s", path)
	fset := token.NewFileSet()
	f, err := parser.ParseFile(fset, path, nil, parser.ParseComments)
	if err != nil {
		return fmt.Errorf("error parsing go file %s: %s", path, err)
	}
	if opts != nil {
		for _, v := range opts.Functions {
			if v.Template {
				continue
			}
			if err := extractGoFunc(messages, fset, f, v); err != nil {
				return err
			}
		}
		for _, v := range opts.Types {
			if err := extractGoType(messages, fset, f, v); err != nil {
				return err
			}
		}
		for _, v := range opts.TagFields {
			if err := extractGoTagField(messages, fset, f, v); err != nil {
				return err
			}
		}
	}
	return nil
}
开发者ID:rainycape,项目名称:gondola,代码行数:29,代码来源:extract.go

示例7: bakeCommand

func bakeCommand(_ *command.Args, opts *bakeOptions) error {
	extensions := []string{".html", ".css", ".js"}
	if opts.Dir == "" {
		return errors.New("dir can't be empty")
	}
	if opts.Name == "" {
		base := filepath.Base(opts.Dir)
		if opts.VFS {
			opts.Name = base + "FS"
		} else {
			opts.Name = base + "Data"
		}
	}
	if opts.Out == "" {
		opts.Out = filepath.Base(opts.Dir) + "_baked.go"
	}
	// go ignores files starting with _
	opts.Out = strings.TrimLeft(opts.Out, "_")
	extensions = append(extensions, strings.Split(opts.Extensions, ",")...)
	var buf bytes.Buffer
	odir := filepath.Dir(opts.Out)
	p, err := build.ImportDir(odir, 0)
	if err == nil {
		buf.WriteString(fmt.Sprintf("package %s\n", p.Name))
	}
	buf.WriteString(genutil.AutogenString())
	if err := writeBakedFSCode(&buf, opts, extensions); err != nil {
		return err
	}
	if err := genutil.WriteAutogen(opts.Out, buf.Bytes()); err != nil {
		return err
	}
	log.Debugf("Assets written to %s (%d bytes)", opts.Out, buf.Len())
	return nil
}
开发者ID:rainycape,项目名称:gondola,代码行数:35,代码来源:bake.go

示例8: Compile

func (t *Template) Compile() error {
	if err := t.noCompiled("can't compile"); err != nil {
		return err
	}
	if err := t.preparePlugins(); err != nil {
		return err
	}
	for _, v := range t.referencedTemplates() {
		if _, ok := t.trees[v]; !ok {
			log.Debugf("adding missing template %q as empty", v)
			tree := compileTree("")
			t.AddParseTree(v, tree)
		}
	}
	if err := t.prepareAssets(); err != nil {
		return err
	}
	prog, err := newProgram(t)
	if err != nil {
		return err
	}
	prog.debugDump()
	t.prog = prog
	return nil
}
开发者ID:rainycape,项目名称:gondola,代码行数:25,代码来源:template.go

示例9: compileMessagesCommand

func compileMessagesCommand(_ *command.Args, opts *compileMessagesOptions) error {
	var poFiles []string
	err := filepath.Walk(opts.Messages, func(path string, info os.FileInfo, err error) error {
		if err != nil {
			return err
		}
		if !info.IsDir() && strings.ToLower(filepath.Ext(path)) == ".po" {
			log.Debugf("compiling po file %s", path)
			poFiles = append(poFiles, path)
		}
		return nil
	})
	if err != nil {
		return err
	}
	pos := make([]*po.Po, len(poFiles))
	for ii, v := range poFiles {
		p, err := po.ParseFile(v)
		if err != nil {
			return err
		}
		pos[ii] = p
	}
	copts := &messages.CompileOptions{DefaultContext: opts.Context}
	return messages.Compile(opts.Out, pos, copts)
}
开发者ID:rainycape,项目名称:gondola,代码行数:26,代码来源:i18n.go

示例10: makeAppAssets

func makeAppAssets(buildArgs []string) ([]string, error) {
	log.Debugf("compiling app assets")
	if err := runBuild(buildArgs); err != nil {
		return nil, err
	}
	p, err := appPath()
	if err != nil {
		return nil, err
	}
	defer os.Remove(p)
	err = runCmd(exec.Command(p, "-log-debug=false", "make-assets"))
	if err != nil {
		return nil, err
	}
	var buf bytes.Buffer
	cmd := exec.Command(p, "_print-resources")
	cmd.Stdout = &buf
	if err := cmd.Run(); err != nil {
		return nil, err
	}
	var m map[string]string
	if err := json.Unmarshal(buf.Bytes(), &m); err != nil {
		return nil, err
	}
	values := make([]string, 0, len(m))
	for _, v := range m {
		values = append(values, v)
	}
	return values, nil
}
开发者ID:rainycape,项目名称:gondola,代码行数:30,代码来源:gae.go

示例11: updatePackage

func updatePackage(e *doc.Environment, pkg string) error {
	if strings.HasSuffix(pkg, "/") {
		pkg += "..."
	}
	goBin := "go"
	env := make(map[string]string)
	for _, v := range os.Environ() {
		if eq := strings.Index(v, "="); eq >= 0 {
			env[v[:eq]] = v[eq+1:]
		}
	}
	if goRoot := e.Context.GOROOT; goRoot != "" {
		goBin = filepath.Join(goRoot, "bin", "go")
		env["GOROOT"] = goRoot
	}
	if goPath := e.Context.GOPATH; goPath != "" {
		env["GOPATH"] = goPath
	}
	cmd := exec.Command(goBin, "get", "-u", "-v", pkg)
	cmdEnv := make([]string, 0, len(env))
	for k, v := range env {
		cmdEnv = append(cmdEnv, k+"="+v)
	}
	cmd.Env = cmdEnv
	log.Debugf("Updating package %s", pkg)
	if log.Level() == log.LDebug {
		cmd.Stdout = os.Stdout
		cmd.Stderr = os.Stderr
	}
	return cmd.Run()
}
开发者ID:rainycape,项目名称:gondola,代码行数:31,代码来源:packages.go

示例12: Initialize

func (d *Driver) Initialize(ms []driver.Model) error {
	// Create tables
	for _, v := range ms {
		tbl, err := d.makeTable(v)
		if err != nil {
			return err
		}
		existingTbl, err := d.backend.Inspect(d.db, v)
		if err != nil {
			return err
		}
		if existingTbl != nil {
			err = d.mergeTable(v, existingTbl, tbl)
		} else {
			if len(tbl.Fields) == 0 {
				log.Debugf("Skipping collection %s (model %v) because it has no fields", v.Table, v)
				continue
			}
			// Table does not exists, create it
			err = d.createTable(v, tbl)
		}
		if err != nil {
			return err
		}
	}
	// Create indexes
	for _, v := range ms {
		if err := d.createIndexes(v); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:rainycape,项目名称:gondola,代码行数:33,代码来源:driver.go

示例13: Open

func (f *fileWriter) Open(name string) error {
	dir, err := os.Stat(f.dir)
	if err != nil || !dir.IsDir() {
		os.Remove(f.dir)
		// Make logs directory
		if err := os.MkdirAll(f.dir, 0755); err != nil {
			return err
		}
	}
	if f.f != nil {
		if err := f.Close(); err != nil {
			return err
		}
	}
	f.name = name
	logPath := f.logPath(0)
	w, err := os.OpenFile(logPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
	if err != nil {
		return fmt.Errorf("error opening log file %s: %s", logPath, err)
	}
	log.Debugf("opened log file %s", name)
	info, err := w.Stat()
	if err != nil {
		w.Close()
		return err
	}
	f.size = uint64(info.Size())
	f.f = w
	return nil
}
开发者ID:rainycape,项目名称:governator,代码行数:30,代码来源:file_writer.go

示例14: Remove

// Remove deletes the file with the given id.
func (s *Blobstore) Remove(id string) error {
	s.drv.Remove(s.metaName(id))
	err := s.drv.Remove(id)
	if err == nil {
		log.Debugf("[BLOBSTORE]: Removed %v", id)
	}
	return err
}
开发者ID:rainycape,项目名称:gondola,代码行数:9,代码来源:blobstore.go

示例15: handleError

func (app *App) handleError(ctx *Context, err interface{}) bool {
	if gerr, ok := err.(Error); ok {
		log.Debugf("HTTP error: %s (%d)", gerr.Error(), gerr.StatusCode())
		app.handleHTTPError(ctx, gerr.Error(), gerr.StatusCode())
		return true
	}
	return false
}
开发者ID:rainycape,项目名称:gondola,代码行数:8,代码来源:app.go


注:本文中的gnd/la/log.Debugf函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。