• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang log4go.Fine函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: RunClang

func RunClang(args ...string) ([]byte, error) {
	cmd := exec.Command("clang", args...)
	log4go.Debug("Running clang command: %v", cmd)

	if e, err := cmd.StderrPipe(); err != nil {
		return nil, err
	} else if s, err := cmd.StdoutPipe(); err != nil {
		return nil, err
	} else if err := cmd.Start(); err != nil {
		return nil, err
	} else {
		so, serr := ioutil.ReadAll(s)
		eo, eerr := ioutil.ReadAll(e)
		// We ignore the output error here as a non-zero exit
		// code doesn't necessarily mean that the output isn't
		// useful
		cmd.Wait()

		log4go.Fine("stdout: %s\n", string(so))
		log4go.Fine("stderr: %s\n", string(eo))
		if serr != nil {
			return nil, serr
		} else if eerr != nil {
			return nil, eerr
		}
		return so, nil
	}
}
开发者ID:jerchung,项目名称:completion,代码行数:28,代码来源:clang.go


示例2: Complete

func (c *Java) Complete(args *content.CompleteArgs, cmp *content.CompletionResult) error {
	log4go.Fine("%+v", args)
	var archive Archive
	session := args.Session()
	if session != nil {
		if a, ok := session.Get("java_archive").(Archive); ok {
			archive = a
		}
	}
	if archive == nil {
		cp, err := DefaultClasspath()
		if err != nil {
			// We don't really care about not being able to get the default classpath as it could be provided manually by the user
			log4go.Warn("Couldn't get the default classpath: %s", err)
		}
		settings := args.Settings()
		if cp2, ok := settings.Get("java_classpath").([]string); ok {
			// TODO: do we ever want to override rather than append to the classpath?
			cp = append(cp, cp2...)
		}
		log4go.Fine("classpath: %+v", cp)
		if archive, err = NewCompositeArchive(cp); err != nil {
			return err
		} else if session != nil {
			session.Set("java_archive", archive)
		}
	}

	className, err := fqnToClassname(args.Location)
	if err != nil {
		return err
	}

	data, err := archive.LoadClass(className)
	if err != nil {
		return err
	}

	class, err := NewClass(bytes.NewReader(data))
	if err != nil {
		return err
	}

	ct, err := class.ToContentType()
	if err != nil {
		return err
	}

	// TODO(q): Inherited fields and methods?
	// 			I see value in being able to "just" get the smaller set,
	//			but getting the full set should definitely be possible "server side"
	cmp.Fields = ct.Fields
	cmp.Types = ct.Types
	cmp.Methods = ct.Methods

	return nil
}
开发者ID:NeoTse,项目名称:completion,代码行数:57,代码来源:java.go


示例3: Call

func (qe QueryContextEvent) Call(v *View, key string, operator Op, operand interface{}, match_all bool) QueryContextReturn {
	log4go.Fine("Query context: %s, %v, %v, %v", key, operator, operand, match_all)
	for i := range qe {
		r := qe[i](v, key, operator, operand, match_all)
		if r != Unknown {
			return r
		}
	}
	log4go.Fine("Unknown context: %s", key)
	return Unknown
}
开发者ID:kiawin,项目名称:lime,代码行数:11,代码来源:events.go


示例4: Yield

func (je *JoinEngine) Yield(s *protocol.Series) (bool, error) {
	log4go.Fine("JoinEngine.Yield(): %s", s)
	idx := je.tableIdx[s.GetName()]
	state := &je.tablesState[idx]
	// If the state for this table didn't contain a point already,
	// increment the number of tables ready to emit a point by
	// incrementing `pts`
	if state.lastPoint == nil {
		je.pts++
	}
	state.lastPoint = s.Points[len(s.Points)-1]
	// update the fields for this table. the fields shouldn't change
	// after the first point, so we only need to set them once
	if state.lastFields == nil {
		for _, f := range s.Fields {
			state.lastFields = append(state.lastFields, s.GetName()+"."+f)
		}
	}

	log4go.Fine("JoinEngine: pts = %d", je.pts)
	// if the number of tables ready to emit a point isn't equal to the
	// total number of tables being joined, then return
	if je.pts != len(je.tablesState) {
		return true, nil
	}

	// we arbitrarily use the timestamp of the first table's point as
	// the timestamp of the resulting point. may be we should use the
	// smalles (or largest) timestamp.
	ts := je.tablesState[0].lastPoint.Timestamp
	newSeries := &protocol.Series{
		Name:   &je.name,
		Fields: je.fields(),
		Points: []*protocol.Point{
			{
				Timestamp: ts,
				Values:    je.values(),
			},
		},
	}

	// filter the point. the user may have a where clause with the join,
	// e.g. `select * from join(foo1, foo2) where foo1.val > 10`. we
	// can't evaluate the where clause until after join happens
	filteredSeries, err := Filter(je.query, newSeries)
	if err != nil {
		return false, err
	}

	if len(filteredSeries.Points) > 0 {
		return je.next.Yield(newSeries)
	}
	return true, nil
}
开发者ID:ericcapricorn,项目名称:influxdb,代码行数:54,代码来源:join_engine.go


示例5: ReturnShard

func (self *ShardDatastore) ReturnShard(id uint32) {
	self.shardsLock.Lock()
	defer self.shardsLock.Unlock()
	log.Fine("Returning shard. id = %d", id)
	self.shardRefCounts[id] -= 1
	if self.shardRefCounts[id] != 0 {
		return
	}

	log.Fine("Checking if shard should be deleted. id = %d", id)
	if _, ok := self.shardsToDelete[id]; ok {
		self.deleteShard(id)
		return
	}

	log.Fine("Checking if shard should be closed. id = %d", id)
	if self.shardsToClose[id] {
		self.closeShard(id)
	}
}
开发者ID:carriercomm,项目名称:facette,代码行数:20,代码来源:shard_datastore.go


示例6: Cache

func (p *Pattern) Cache(data string, pos int) (pat *Pattern, ret MatchObject) {
	if p.cachedData == data {
		if p.cachedMatch == nil {
			return nil, nil
		}
		if p.cachedMatch[0] >= pos && p.cachedPat.cachedMatch != nil {
			p.hits++
			return p.cachedPat, p.cachedMatch
		}
	} else {
		p.cachedPatterns = nil
	}
	if p.cachedPatterns == nil {
		p.cachedPatterns = make([]*Pattern, len(p.Patterns))
		for i := range p.cachedPatterns {
			p.cachedPatterns[i] = &p.Patterns[i]
		}
	}
	p.misses++

	if p.Match.re != nil {
		pat, ret = p, p.Match.Find(data, pos)
	} else if p.Begin.re != nil {
		pat, ret = p, p.Begin.Find(data, pos)
	} else if p.Include != "" {
		if z := p.Include[0]; z == '#' {
			key := p.Include[1:]
			if p2, ok := p.owner.Repository[key]; ok {
				pat, ret = p2.Cache(data, pos)
			} else {
				log4go.Fine("Not found in repository: %s", p.Include)
			}
		} else if z == '$' {
			// TODO(q): Implement tmLanguage $ include directives
			log4go.Warn("Unhandled include directive: %s", p.Include)
		} else if l, err := Provider.GetLanguage(p.Include); err != nil {
			if !failed[p.Include] {
				log4go.Warn("Include directive %s failed: %s", p.Include, err)
			}
			failed[p.Include] = true
		} else {
			return l.RootPattern.Cache(data, pos)
		}
	} else {
		pat, ret = p.FirstMatch(data, pos)
	}
	p.cachedData = data
	p.cachedMatch = ret
	p.cachedPat = pat

	return
}
开发者ID:richardfontana,项目名称:lime,代码行数:52,代码来源:language.go


示例7: Fields

func (td *TypeDef) Fields() (fields []content.Field, err error) {
	if td.ct.Name.Relative != "" {
		return td.ct.Fields, nil
	}

	var (
		mu               = td.index.(*ConcreteTableIndex).metadataUtil
		startRow, endRow = td.ListRange(td.index.Index(), id_TypeDef, id_Field, func(i interface{}) uint32 { return i.(*TypeDefRow).FieldList.Index() })
		idx              = ConcreteTableIndex{mu, startRow, id_Field}
	)
	cn := stripProto(td.Name().Absolute)
	for i := startRow; i < endRow; i++ {
		idx.index = i
		if rawfield, err := idx.Data(); err != nil {
			return nil, err
		} else {
			var (
				field = rawfield.(*FieldRow)
				f     content.Field
				dec   *SignatureDecoder
				sig   FieldSig
			)
			f.Name.Relative = string(field.Name)
			f.Name.Absolute = fmt.Sprintf("net://field/%s;%d", cn, i-startRow)
			if dec, err = NewSignatureDecoder(field.Signature); err != nil {
				return nil, err
			} else if err = dec.Decode(&sig); err != nil {
				return nil, err
			} else {
				f.Type = td.initContentType(td.index, &sig.Type)
			}
			if field.Flags&FieldAttributes_Static != 0 {
				f.Flags |= content.FLAG_STATIC
			}
			if field.Flags&FieldAttributes_Public != 0 {
				f.Flags |= content.FLAG_ACC_PUBLIC
			} else if field.Flags&FieldAttributes_Private != 0 {
				f.Flags |= content.FLAG_ACC_PRIVATE
			} else if field.Flags&FieldAttributes_Family != 0 {
				f.Flags |= content.FLAG_ACC_PROTECTED
			}
			if err := check(&f, f.Name); err != nil {
				log4go.Fine("Skipping field: %s, %+v, %+v", err, f, field)
				continue
			}
			fields = append(fields, f)
		}
	}
	return fields, nil
}
开发者ID:jerchung,项目名称:completion,代码行数:50,代码来源:typedef.go


示例8: RunApplicationCommand

func (ch *commandHandler) RunApplicationCommand(name string, args Args) error {
	p := Prof.Enter("ac")
	defer p.Exit()
	if ch.log {
		log4go.Info("Running application command: %s %v", name, args)
	} else {
		log4go.Fine("Running application command: %s %v", name, args)
	}
	if c := ch.ApplicationCommands[name]; c != nil {
		if err := c.Run(args); err != nil && ch.verbose {
			log4go.Debug("Command execution failed: %s", err)
		}
	}
	return nil
}
开发者ID:richardfontana,项目名称:lime,代码行数:15,代码来源:commandhandler.go


示例9: DeleteShard

func (self *ShardDatastore) DeleteShard(shardId uint32) {
	self.shardsLock.Lock()
	defer self.shardsLock.Unlock()
	// If someone has a reference to the shard we can't delete it
	// now. We have to wait until it's returned and delete
	// it. ReturnShard will take care of that as soon as the reference
	// count becomes 0.
	if refc := self.shardRefCounts[shardId]; refc > 0 {
		log.Fine("Cannot delete shard: shardId = %d, shardRefCounts[shardId] = %d", shardId, refc)
		self.shardsToDelete[shardId] = struct{}{}
		return
	}

	// otherwise, close the shard and delete it now
	self.deleteShard(shardId)
}
开发者ID:carriercomm,项目名称:facette,代码行数:16,代码来源:shard_datastore.go


示例10: EndEdit

func (v *View) EndEdit(edit *Edit) {
	if edit.invalid {
		log4go.Fine("This edit has already been invalidated: %v, %v", edit, v.editstack)
		return
	}
	i := len(v.editstack) - 1
	for i := len(v.editstack) - 1; i >= 0; i-- {
		if v.editstack[i] == edit {
			break
		}
	}
	if i == -1 {
		log4go.Error("This edit isn't even in the stack... where did it come from? %v, %v", edit, v.editstack)
		return
	}

	var selmod bool

	if l := len(v.editstack) - 1; i != l {
		log4go.Error("This edit wasn't last in the stack... %d !=  %d: %v, %v", i, l, edit, v.editstack)
	}
	for j := len(v.editstack) - 1; j >= i; j-- {
		ce := v.editstack[j]
		ce.invalid = true
		is := reflect.DeepEqual(*v.Sel(), ce.savedSel)
		ib := v.buffer.ChangeCount() == ce.savedCount
		eq := (is && ib && ce.composite.Len() == 0)
		if !eq && is {
			selmod = true
		}
		if v.scratch || ce.bypassUndo || eq {
			continue
		}
		if i == 0 || j != i {
			// Presume someone forgot to add it in the j != i case
			v.undoStack.Add(edit)
		} else {
			// This edit belongs to another edit
			v.editstack[i-1].composite.Add(ce)
		}
	}
	v.editstack = v.editstack[:i]
	if selmod {
		OnSelectionModified.Call(v)
	}
}
开发者ID:nicecai,项目名称:lime,代码行数:46,代码来源:view.go


示例11: SaveAs

// Saves the file to the specified filename
func (v *View) SaveAs(name string) (err error) {
	log4go.Fine("SaveAs(%s)", name)
	v.Settings().Set("lime.saving", true)
	defer v.Settings().Erase("lime.saving")
	var atomic bool
	OnPreSave.Call(v)
	if atomic, _ = v.Settings().Get("atomic_save", true).(bool); v.buffer.FileName() == "" || !atomic {
		if err := v.nonAtomicSave(name); err != nil {
			return err
		}
	} else {
		n, err := ioutil.TempDir(path.Dir(v.buffer.FileName()), "lime")
		if err != nil {
			return err
		}
		tmpf := path.Join(n, "tmp")
		if err := v.nonAtomicSave(tmpf); err != nil {
			return err
		}
		if err := os.Rename(tmpf, name); err != nil {
			// When we wan't to save as a file in another directory
			// we can't go with os.Rename so we need to force
			// not atomic saving sometimes as 4th test in TestSaveAsOpenFile
			if err := v.nonAtomicSave(name); err != nil {
				return err
			}
		}
		if err := os.RemoveAll(n); err != nil {
			return err
		}
	}

	ed := GetEditor()
	if v.buffer.FileName() != name {
		v.Buffer().SetFileName(name)
		// TODO(.): There could be multiple watchers tied to a single filename...
		ed.UnWatch(v.buffer.FileName())
		ed.Watch(NewWatchedUserFile(v))
	}

	v.buffer.Settings().Set("lime.last_save_change_count", v.buffer.ChangeCount())
	OnPostSave.Call(v)
	return nil
}
开发者ID:BinaryPaean,项目名称:lime,代码行数:45,代码来源:view.go


示例12: CheckForUpdatedConfigs

func CheckForUpdatedConfigs(auto_update string, config_url string, api_key string, output_dir string, agent_bin string, out chan<- *AgentConfigType, defaults Consts) {
	for {
		config_data := ParseJsonFromHttp(config_url, api_key)
		out <- &config_data

		if auto_update == "true" && config_data.Version != defaults.Current_build {
			l4g.Debug("Upgrading agent version-%s\n", config_data.Version)
			hdata := config_data.Sha256
			if runtime.GOARCH == "amd64" {
				hdata = config_data.Sha256_amd64
			}
			Upgrade_version(config_data.Version, hdata, output_dir, agent_bin, defaults)
			l4g.Debug("Failed upgrading!\n")
		} else {
			l4g.Fine("Don't need to upgrade versions\n")
		}
		time.Sleep(10 * time.Second)
	}

}
开发者ID:pombredanne,项目名称:ranger-1,代码行数:20,代码来源:config.go


示例13: StoreParsedURL

func (ds *CassandraDatastore) StoreParsedURL(u *URL, fr *FetchResults) {
	if !u.IsAbs() {
		log4go.Warn("Link should not have made it to StoreParsedURL: %v", u)
		return
	}
	dom, subdom, err := u.TLDPlusOneAndSubdomain()
	if err != nil {
		log4go.Debug("StoreParsedURL not storing %v: %v", fr.URL, err)
		return
	}

	if Config.AddNewDomains {
		ds.addDomainIfNew(dom)
	}
	log4go.Fine("Inserting parsed URL: %v", u)
	err = ds.db.Query(`INSERT INTO links (dom, subdom, path, proto, time)
						VALUES (?, ?, ?, ?, ?)`,
		dom, subdom, u.RequestURI(), u.Scheme, NotYetCrawled).Exec()
	if err != nil {
		log4go.Error("failed inserting parsed url (%v) to cassandra, %v", u, err)
	}
}
开发者ID:pombredanne,项目名称:walker-2,代码行数:22,代码来源:datastore.go


示例14: onEvent

func (c *ViewEventGlue) onEvent(v *backend.View) {
	l := py.NewLock()
	defer l.Unlock()
	if pv, err := toPython(v); err != nil {
		log4go.Error(err)
	} else {
		defer pv.Decref()
		log4go.Fine("onEvent: %v, %v, %v", c, c.inner, pv)
		// interrupt := true
		// defer func() { interrupt = false }()
		// go func() {
		// 	<-time.After(time.Second * 5)
		// 	if interrupt {
		// 		py.SetInterrupt()
		// 	}
		// }()

		if ret, err := c.inner.Base().CallFunctionObjArgs(pv); err != nil {
			log4go.Error(err)
		} else if ret != nil {
			ret.Decref()
		}
	}
}
开发者ID:networkpku,项目名称:lime,代码行数:24,代码来源:events_manual.go


示例15: start

// start blocks until the fetcher has completed by being told to quit.
func (f *fetcher) start() {
	log4go.Debug("Starting new fetcher")
	for {
		if f.host != "" {
			//TODO: ensure that this unclaim will happen... probably want the
			//logic below in a function where the Unclaim is deferred
			log4go.Info("Finished crawling %v, unclaiming", f.host)
			f.fm.Datastore.UnclaimHost(f.host)
		}

		select {
		case <-f.quit:
			f.done <- struct{}{}
			return
		default:
		}

		f.host = f.fm.Datastore.ClaimNewHost()
		if f.host == "" {
			time.Sleep(time.Second)
			continue
		}

		if f.checkForBlacklisting(f.host) {
			continue
		}

		f.fetchRobots(f.host)
		f.crawldelay = time.Duration(Config.DefaultCrawlDelay) * time.Second
		if f.robots != nil && int(f.robots.CrawlDelay) > Config.DefaultCrawlDelay {
			f.crawldelay = f.robots.CrawlDelay
		}
		log4go.Info("Crawling host: %v with crawl delay %v", f.host, f.crawldelay)

		for link := range f.fm.Datastore.LinksForHost(f.host) {
			//TODO: check <-f.quit and clean up appropriately

			fr := &FetchResults{URL: link}

			if f.robots != nil && !f.robots.Test(link.String()) {
				log4go.Debug("Not fetching due to robots rules: %v", link)
				fr.ExcludedByRobots = true
				f.fm.Datastore.StoreURLFetchResults(fr)
				continue
			}

			time.Sleep(f.crawldelay)

			fr.FetchTime = time.Now()
			fr.Response, fr.RedirectedFrom, fr.FetchError = f.fetch(link)
			if fr.FetchError != nil {
				log4go.Debug("Error fetching %v: %v", link, fr.FetchError)
				f.fm.Datastore.StoreURLFetchResults(fr)
				continue
			}
			log4go.Debug("Fetched %v -- %v", link, fr.Response.Status)

			ctype, ctypeOk := fr.Response.Header["Content-Type"]
			if ctypeOk && len(ctype) > 0 {
				media_type, _, err := mime.ParseMediaType(ctype[0])
				if err != nil {
					log4go.Error("Failed to parse mime header %q: %v", ctype[0], err)
				} else {
					fr.MimeType = media_type
				}
			}

			canSearch := isHTML(fr.Response)
			if canSearch {
				log4go.Debug("Reading and parsing as HTML (%v)", link)

				//TODO: ReadAll is inefficient. We should use a properly sized
				//		buffer here (determined by
				//		Config.MaxHTTPContentSizeBytes or possibly
				//		Content-Length of the response)
				var body []byte
				body, fr.FetchError = ioutil.ReadAll(fr.Response.Body)
				if fr.FetchError != nil {
					log4go.Debug("Error reading body of %v: %v", link, fr.FetchError)
					f.fm.Datastore.StoreURLFetchResults(fr)
					continue
				}
				fr.Response.Body = ioutil.NopCloser(bytes.NewReader(body))

				outlinks, err := getLinks(body)
				if err != nil {
					log4go.Debug("error parsing HTML for page %v: %v", link, err)
				} else {
					for _, outlink := range outlinks {
						outlink.MakeAbsolute(link)
						log4go.Fine("Parsed link: %v", outlink)
						if shouldStore(outlink) {
							f.fm.Datastore.StoreParsedURL(outlink, fr)
						}
					}
				}
			}

			// handle any doc that we searched or that is in our AcceptFormats
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:walker-2,代码行数:101,代码来源:fetcher.go


示例16: CommitSeriesData

func (self *Coordinator) CommitSeriesData(db string, serieses []*protocol.Series, sync bool) error {
	now := common.CurrentTime()

	shardToSerieses := map[uint32]map[string]*protocol.Series{}
	shardIdToShard := map[uint32]*cluster.ShardData{}

	for _, series := range serieses {
		if len(series.Points) == 0 {
			return fmt.Errorf("Can't write series with zero points.")
		}

		for _, point := range series.Points {
			if point.Timestamp == nil {
				point.Timestamp = &now
			}
		}

		// sort the points by timestamp
		// TODO: this isn't needed anymore
		series.SortPointsTimeDescending()

		sn := series.GetName()
		// use regular for loop since we update the iteration index `i' as
		// we batch points that have the same timestamp
		for i := 0; i < len(series.Points); {
			if len(series.GetName()) == 0 {
				return fmt.Errorf("Series name cannot be empty")
			}

			ts := series.Points[i].GetTimestamp()
			shard, err := self.clusterConfiguration.GetShardToWriteToBySeriesAndTime(db, sn, ts)
			if err != nil {
				return err
			}
			log.Fine("GetShardToWriteToBySeriesAndTime(%s, %s, %d) = (%s, %v)", db, sn, ts, shard, err)
			firstIndex := i
			for ; i < len(series.Points) && series.Points[i].GetTimestamp() == ts; i++ {
				// add all points with the same timestamp
			}

			// if shard == nil, then the points shouldn't be writte. This
			// will happen if the points had timestamps earlier than the
			// retention period
			if shard == nil {
				continue
			}
			newSeries := &protocol.Series{Name: series.Name, Fields: series.Fields, Points: series.Points[firstIndex:i:i]}

			shardIdToShard[shard.Id()] = shard
			shardSerieses := shardToSerieses[shard.Id()]
			if shardSerieses == nil {
				shardSerieses = map[string]*protocol.Series{}
				shardToSerieses[shard.Id()] = shardSerieses
			}
			seriesName := series.GetName()
			s := shardSerieses[seriesName]
			if s == nil {
				shardSerieses[seriesName] = newSeries
				continue
			}
			shardSerieses[seriesName] = common.MergeSeries(s, newSeries)
		}
	}

	for id, serieses := range shardToSerieses {
		shard := shardIdToShard[id]

		seriesesSlice := make([]*protocol.Series, 0, len(serieses))
		for _, s := range serieses {
			seriesesSlice = append(seriesesSlice, s)
		}

		err := self.write(db, seriesesSlice, shard, sync)
		if err != nil {
			log.Error("COORD error writing: ", err)
			return err
		}
	}

	return nil
}
开发者ID:carriercomm,项目名称:facette,代码行数:81,代码来源:coordinator.go


示例17: Errplane_main

func Errplane_main(defaults econfig.Consts) {
	fmt.Printf("ERRPlane Local Agent starting, Version %s \n", defaults.Current_build)

	goopt.Description = func() string {
		return "ERRPlane Local Agent."
	}
	goopt.Version = defaults.Current_build
	goopt.Summary = "ErrPlane Log and System Monitor"
	goopt.Parse(nil)

	var fconfig_file string
	fconfig_file = *config_file

	fmt.Printf("Loading config file %s.\n", fconfig_file)

	c, err := config.ReadDefault(fconfig_file)
	if err != nil {
		log.Fatal("Can not find the Errplane Config file, please install it in /etc/ranger/ranger.conf.")
	}

	api_key, _ := c.String("DEFAULT", "api_key")

	if len(*install_api_key) > 1 {
		fmt.Printf("Saving new Config!\n")
		c.AddOption("DEFAULT", "api_key", *install_api_key)
		c.WriteFile(fconfig_file, 0644, "")

		c, err := config.ReadDefault(fconfig_file)
		if err != nil {
			log.Fatal("Can not find the Errplane Config file, please install it in /etc/ranger/ranger.conf.")
		}
		api_key, _ = c.String("DEFAULT", "api_key")
	}

	if len(api_key) < 1 {
		log.Fatal("No api key found. Please rerun this with --install-api-key <api_key_here> ")
		os.Exit(1)
	}

	if !*amForeground {
		//Daemonizing requires root
		if os.Getuid() == 0 {
			daemonize.Do_fork(os.Args[0], fconfig_file)
			l4g.Fine("Exiting parent process-%s\n", os.Args[0])
			os.Exit(0)
		} else {
			fmt.Printf("Daemoning requires root \n")
			os.Exit(1)
		}
	}

	setup_logger()

	api_url, _ := c.String("DEFAULT", "api_host")
	config_url, _ := c.String("DEFAULT", "config_host")
	output_dir, _ := c.String("DEFAULT", "agent_path")
	if len(output_dir) < 1 {
		output_dir = "/usr/local/ranger/"
	}
	agent_bin, _ := c.String("DEFAULT", "agent_bin")
	if len(agent_bin) < 1 {
		agent_bin = "/usr/local/bin/ranger-local-agent"
	}
	pid_location, _ := c.String("DEFAULT", "pid_file")
	if len(pid_location) < 1 {
		pid_location = "/var/run/ranger/ranger.pid"
	}
	auto_update, _ := c.String("DEFAULT", "auto_upgrade")

	write_pid(pid_location)

	config_data := econfig.ParseJsonFromHttp(config_url, api_key)

	l4g.Debug("Expected agent version-%s\n", config_data.Version)

	if auto_update == "true" && config_data.Version != defaults.Current_build {
		econfig.Upgrade_version(config_data.Version, config_data.Sha256, output_dir, agent_bin, defaults)
		os.Exit(1)
	} else {
		l4g.Debug("Don't need to upgrade versions\n")
	}

	_, err = exec.LookPath("tail")
	if err != nil {
		log.Fatal("installing tail is in your future")
		//        exit(1)
	}

	configChan := make(chan *econfig.AgentConfigType)

	go theBrain(configChan, api_key, api_url)

	go econfig.CheckForUpdatedConfigs(auto_update, config_url, api_key, output_dir, agent_bin, configChan, defaults)

	if err != nil {
		log.Fatal(err)
	}

	err = nil
	for err == nil {
//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:ranger-1,代码行数:101,代码来源:local_agent.go


示例18: EndEdit

// Ends the given Edit object.
func (v *View) EndEdit(edit *Edit) {
	if edit.invalid {
		// This happens when nesting Edits and the child Edit ends after the parent edit.
		log4go.Fine("This edit has already been invalidated: %v, %v", edit, v.editstack)
		return
	}

	// Find the position of this Edit object in this View's Edit stack.
	// If plugins, commands, etc are well-behaved the ended edit should be
	// last in the stack, but shit happens and we cannot count on this being the case.
	i := len(v.editstack) - 1
	for i := len(v.editstack) - 1; i >= 0; i-- {
		if v.editstack[i] == edit {
			break
		}
	}
	if i == -1 {
		// TODO(.): Under what instances does this happen again?
		log4go.Error("This edit isn't even in the stack... where did it come from? %v, %v", edit, v.editstack)
		return
	}

	var selection_modified bool

	if l := len(v.editstack) - 1; i != l {
		// TODO(.): See TODO in BeginEdit
		log4go.Error("This edit wasn't last in the stack... %d !=  %d: %v, %v", i, l, edit, v.editstack)
	}

	// Invalidate all Edits "below" and including this Edit.
	for j := len(v.editstack) - 1; j >= i; j-- {
		current_edit := v.editstack[j]
		current_edit.invalid = true
		sel_same := reflect.DeepEqual(*v.Sel(), current_edit.savedSel)
		buf_same := v.buffer.ChangeCount() == current_edit.savedCount
		eq := (sel_same && buf_same && current_edit.composite.Len() == 0)
		if !eq && !sel_same {
			selection_modified = true
		}
		if v.scratch || current_edit.bypassUndo || eq {
			continue
		}
		switch {
		case i == 0:
			// Well-behaved, no nested edits!
			fallthrough
		case j != i:
			// BOO! Someone began another Edit without finishing the first one.
			// In this instance, the parent Edit ended before the child.
			// TODO(.): What would be the correct way to handle this?
			v.undoStack.Add(edit)
		default:
			// BOO! Also poorly-behaved. This Edit object began after the parent began,
			// but was finished before the parent finished.
			//
			// Add it as a child of the parent Edit so that undoing the parent
			// will undo this edit as well.
			v.editstack[i-1].composite.Add(current_edit)
		}
	}
	// Pop this Edit and all the children off the Edit stack.
	v.editstack = v.editstack[:i]
	if selection_modified {
		OnSelectionModified.Call(v)
	}
}
开发者ID:BinaryPaean,项目名称:lime,代码行数:67,代码来源:view.go


示例19: SaveAs

// Saves the file to the specified filename
func (v *View) SaveAs(name string) (err error) {
	log4go.Fine("SaveAs(%s)", name)
	v.Settings().Set("lime.saving", true)
	defer v.Settings().Erase("lime.saving")
	var atomic bool
	OnPreSave.Call(v)
	if v.buffer.FileName() != "" {
		atomic, _ = v.Settings().Get("atomic_save", true).(bool)
	} else {
		atomic = false
	}
	var f *os.File
	if atomic {
		f, err = ioutil.TempFile(path.Dir(v.buffer.FileName()), "lime")
	} else {
		f, err = os.Create(name)
	}
	if err != nil {
		return err
	}
	data := []byte(v.buffer.Substr(Region{0, v.buffer.Size()}))
	for len(data) != 0 {
		var n int
		n, err = f.Write(data)
		if n > 0 {
			data = data[n:]
		}
		if err != nil {
			f.Close()
			if atomic {
				os.Remove(f.Name())
			}
			return err
		}
	}
	f.Close()
	if atomic {
		if err = os.Rename(f.Name(), name); err != nil {
			os.Remove(f.Name())
			// When we wan't to save as a file in another directory
			// we can not go with os.Rename so we need to force
			// not atomic saving sometimes as 4th test in TestSaveAsOpenFile
			hold, _ := v.Settings().Get("atomic_save", true).(bool)
			v.Settings().Set("atomic_save", false)
			v.SaveAs(name)
			v.Settings().Set("atomic_save", hold)
		}
	}

	ed := GetEditor()
	if v.buffer.FileName() != name {
		v.Buffer().SetFileName(name)
		// TODO(.): There could be multiple watchers tied to a single filename...
		ed.UnWatch(v.buffer.FileName())
		ed.Watch(NewWatchedUserFile(v))
	}

	v.buffer.Settings().Set("lime.last_save_change_count", v.buffer.ChangeCount())
	OnPostSave.Call(v)
	return nil
}
开发者ID:qcghdy,项目名称:lime,代码行数:62,代码来源:view.go


示例20: Methods

func (td *TypeDef) Methods() (methods []content.Method, err error) {
	if td.ct.Name.Relative != "" {
		return td.ct.Methods, nil
	}

	var (
		mu               = td.index.(*ConcreteTableIndex).metadataUtil
		startRow, endRow = td.ListRange(td.index.Index(), id_TypeDef, id_MethodDef, func(i interface{}) uint32 { return i.(*TypeDefRow).MethodList.Index() })
		idx              = &ConcreteTableIndex{mu, startRow, id_MethodDef}
	)
	cn := stripProto(td.Name().Absolute)
	for i := startRow; i < endRow; i++ {
		idx.index = i
		if rawmethod, err := idx.Data(); err != nil {
			return nil, err
		} else {
			var (
				m      content.Method
				method = rawmethod.(*MethodDefRow)
				dec    *SignatureDecoder
				sig    MethodDefSig
			)
			if n := string(method.Name); n == ".cctor" {
				// Static constructor, we don't care about that one
				continue
			} else {
				m.Name.Relative = n
			}
			m.Name.Absolute = fmt.Sprintf("net://method/%s;%d", cn, i-startRow)
			if m.Parameters, err = td.Parameters(idx); err != nil {
				return nil, err
			}
			if dec, err = NewSignatureDecoder(method.Signature); err != nil {
				return nil, err
			} else if err = dec.Decode(&sig); err != nil {
				return nil, err
			} else {
				// TODO: need to figure out why this mismatch happens
				l := len(sig.Params)
				if l2 := len(m.Parameters); l2 < l {
					l = l2
				}
				for i := range sig.Params[:l] {
					m.Parameters[i].Type = td.initContentType(td.index, &sig.Params[i].Type)
				}
				if method.Flags&MethodAttributes_Final != 0 {
					m.Flags |= content.FLAG_FINAL
				}
				if method.Flags&MethodAttributes_Static != 0 {
					m.Flags |= content.FLAG_STATIC
				}
				if method.Flags&MethodAttributes_Public != 0 {
					m.Flags |= content.FLAG_ACC_PUBLIC
				} else if method.Flags&MethodAttributes_Private != 0 {
					m.Flags |= content.FLAG_ACC_PRIVATE
				} else if method.Flags&MethodAttributes_Family != 0 {
					m.Flags |= content.FLAG_ACC_PROTECTED
				}
				if m.Name.Relative == ".ctor" {
					m.Name.Relative = td.row.Name()
					m.Flags |= content.FLAG_CONSTRUCTOR
				} else {
					m.Returns = make([]content.Variable, 1)
					m.Returns[0].Type = td.initContentType(td.index, &sig.RetType.Type)
				}
			}
			if err := check(&m, m.Name); err != nil {
				log4go.Fine("Skipping method: %s, %+v, %+v", err, m, method)
				continue
			}

			methods = append(methods, m)
		}
	}
	return methods, nil
}
开发者ID:jerchung,项目名称:completion,代码行数:76,代码来源:typedef.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang log4go.Finest函数代码示例发布时间:2022-05-24
下一篇:
Golang log4go.Exit函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap