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

Golang tracelog.COMPLETED函数代码示例

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

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



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

示例1: DecodeSlice

// DecodeSlice decodes a JSON document array into a slice of Go native objects
func DecodeSlice(doc []byte, sliceObj interface{}, obj interface{}) (bool, error) {
	tracelog.STARTED("utils", "DecodeSlice")

	if IsArrayResponse(doc) == false {
		//decode as struct
		if err := Decode(doc, obj); err != nil {
			tracelog.ERROR(err, "utils", "DecodeSlice, Item Not Array, Unable to decode as struct")
			return false, err
		}

		//return false since not an array
		return false, nil
	}

	sliceMap := []map[string]interface{}{}

	if err := json.Unmarshal(doc, &sliceMap); err != nil {
		tracelog.ERROR(err, "utils", "DecodeSlice")
		return false, err
	}

	if err := mapstructure.DecodeSlicePath(sliceMap, sliceObj); err != nil {
		tracelog.ERROR(err, "utils", "DecodeSlice, Decoding Slice Object")
		return false, err
	}

	tracelog.COMPLETED("utils", "DecodeSlice")
	return true, nil
}
开发者ID:swizzley,项目名称:go-common,代码行数:30,代码来源:decoder.go


示例2: FindStation

// FindStation retrieves the specified station
func FindStation(service *services.Service, stationId string) (buoyStation *buoyModels.BuoyStation, err error) {
	defer helper.CatchPanic(&err, service.UserId, "FindStation")

	tracelog.STARTED(service.UserId, "FindStation")

	queryMap := bson.M{"station_id": stationId}

	buoyStation = &buoyModels.BuoyStation{}
	err = service.DBAction(Config.Database, "buoy_stations",
		func(collection *mgo.Collection) error {
			tracelog.TRACE(service.UserId, "FindStation", "Query : %s", mongo.ToString(queryMap))
			return collection.Find(queryMap).One(buoyStation)
		})

	if err != nil {
		if strings.Contains(err.Error(), "not found") == false {
			tracelog.COMPLETED_ERROR(err, service.UserId, "FindStation")
			return buoyStation, err
		}

		err = nil
	}

	tracelog.COMPLETED(service.UserId, "FindStation")
	return buoyStation, err
}
开发者ID:johnzan,项目名称:beego-mgo,代码行数:27,代码来源:buoyService.go


示例3: CloseSession

// CloseSession puts the connection back into the pool
func CloseSession(sessionId string, mongoSession *mgo.Session) {
	defer helper.CatchPanic(nil, sessionId, "CloseSession")

	tracelog.STARTED(sessionId, "CloseSession")

	mongoSession.Close()

	tracelog.COMPLETED(sessionId, "CloseSession")
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:10,代码来源:mongo.go


示例4: Finish

// Finish is called once the controller method completes
func Finish(service *services.Service) {
	defer func() {
		if service.MongoSession != nil {
			mongo.CloseSession(service.UserId, service.MongoSession)
			service.MongoSession = nil
		}
	}()

	tracelog.COMPLETED(service.UserId, "Finish")
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:11,代码来源:serviceTests.go


示例5: Shutdown

// Shutdown systematically brings the manager down gracefully
func Shutdown(sessionId string) (err error) {
	defer helper.CatchPanic(&err, sessionId, "Shutdown")

	tracelog.STARTED(sessionId, "Shutdown")

	// Close the databases
	for _, session := range _This.sessions {
		CloseSession(sessionId, session.mongoSession)
	}

	tracelog.COMPLETED(sessionId, "Shutdown")
	return err
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:14,代码来源:mongo.go


示例6: CreateSession

// CreateSession creates a connection pool for use
func CreateSession(sessionId string, mode string, sessionName string, hosts []string, databaseName string, username string, password string) (err error) {
	defer helper.CatchPanic(nil, sessionId, "CreateSession")

	tracelog.STARTEDf(sessionId, "CreateSession", "Mode[%s] SessionName[%s] Hosts[%s] DatabaseName[%s] Username[%s]", mode, sessionName, hosts, databaseName, username)

	// Create the database object
	mongoSession := &mongoSession{
		mongoDBDialInfo: &mgo.DialInfo{
			Addrs:    hosts,
			Timeout:  60 * time.Second,
			Database: databaseName,
			Username: username,
			Password: password,
		},
	}

	// Establish the master session
	mongoSession.mongoSession, err = mgo.DialWithInfo(mongoSession.mongoDBDialInfo)
	if err != nil {
		tracelog.COMPLETED_ERROR(err, sessionId, "CreateSession")
		return err
	}

	switch mode {
	case "strong":
		// Reads and writes will always be made to the master server using a
		// unique connection so that reads and writes are fully consistent,
		// ordered, and observing the most up-to-date data.
		// http://godoc.org/labix.org/v2/mgo#Session.SetMode
		mongoSession.mongoSession.SetMode(mgo.Strong, true)
		break

	case "monotonic":
		// Reads may not be entirely up-to-date, but they will always see the
		// history of changes moving forward, the data read will be consistent
		// across sequential queries in the same session, and modifications made
		// within the session will be observed in following queries (read-your-writes).
		// http://godoc.org/labix.org/v2/mgo#Session.SetMode
		mongoSession.mongoSession.SetMode(mgo.Monotonic, true)
	}

	// Have the session check for errors
	// http://godoc.org/labix.org/v2/mgo#Session.SetSafe
	mongoSession.mongoSession.SetSafe(&mgo.Safe{})

	// Add the database to the map
	_This.sessions[sessionName] = mongoSession

	tracelog.COMPLETED(sessionId, "CreateSession")
	return err
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:52,代码来源:mongo.go


示例7: Station

// Station handles the higher level business processing for this API Call
func Station(controller *bc.BaseController, stationId string) {
	defer bc.CatchPanic(controller, "Station")

	tracelog.STARTEDf(controller.UserId, "Station", "StationId[%s]", stationId)

	buoyStation, err := buoyService.FindStation(&controller.Service, stationId)
	if err != nil {
		tracelog.COMPLETED_ERRORf(err, controller.UserId, "Station", "StationId[%s]", stationId)
		controller.ServeError(err)
		return
	}

	controller.Data["json"] = &buoyStation
	controller.ServeJson()

	tracelog.COMPLETED(controller.UserId, "Station")
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:18,代码来源:buoyBusiness.go


示例8: Region

// Region handles the higher level business processing for this API Call
func Region(controller *bc.BaseController, region string) {
	defer bc.CatchPanic(controller, "Region")

	tracelog.STARTEDf(controller.UserId, "Region", "Region[%s]", region)

	buoyStations, err := buoyService.FindRegion(&controller.Service, region)
	if err != nil {
		tracelog.COMPLETED_ERRORf(err, controller.UserId, "Region", "Region[%s]", region)
		controller.ServeError(err)
		return
	}

	controller.Data["json"] = &buoyStations
	controller.ServeJson()

	tracelog.COMPLETED(controller.UserId, "Region")
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:18,代码来源:buoyBusiness.go


示例9: Init

// Init initializes the local environment
func Init(defaultLocale string) error {
	tracelog.STARTEDf("localize", "Init", "DefaultLocal[%s]", defaultLocale)

	switch defaultLocale {
	default:
		LoadJSON(defaultLocale, loc.En_US)
	}

	// Obtain the default translation function for use
	var err error
	T, err = NewTranslation(defaultLocale)
	if err != nil {
		return err
	}

	tracelog.COMPLETED("localize", "Init")
	return nil
}
开发者ID:swizzley,项目名称:go-common,代码行数:19,代码来源:messages.go


示例10: loadResponse

// loadResponse parse a response.
func loadResponse(resp *http.Response) ([]byte, error) {
	tracelog.STARTED("http_client", "loadResponse")

	contents, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

	defer resp.Body.Close()

	tracelog.INFO("yodlee_api", "loadResponse", "Api Response => \n\n %s \n\n", contents)

	if resp.StatusCode != 200 {
		return nil, errors.New(string(contents))
	}

	tracelog.COMPLETED("http_client", "loadResponse")
	return contents, err
}
开发者ID:swizzley,项目名称:go-common,代码行数:20,代码来源:http_client.go


示例11: Init

// Init initializes the local environment
func Init(defaultLocale string) error {
	tracelog.STARTEDf("localize", "Init", "DefaultLocal[%s]", defaultLocale)

	switch defaultLocale {
	case "en-US":
		LoadJSON(defaultLocale, En_US)
	default:
		return fmt.Errorf("Unsupported Locale: %s", defaultLocale)
	}

	// Obtain the default translation function for use
	var err error
	T, err = NewTranslation(defaultLocale, defaultLocale)
	if err != nil {
		return err
	}

	tracelog.COMPLETED("localize", "Init")
	return nil
}
开发者ID:johnzan,项目名称:beego-mgo,代码行数:21,代码来源:messages.go


示例12: CloneSession

// CopySession makes a clone of the specified session for client use
func CloneSession(sessionId string, useSession string) (mongoSession *mgo.Session, err error) {
	defer helper.CatchPanic(nil, sessionId, "CopySession")

	tracelog.STARTEDf(sessionId, "CloneSession", "UseSession[%s]", useSession)

	// Find the session object
	session := _This.sessions[useSession]

	if session == nil {
		err = fmt.Errorf("Unable To Locate Session %s", useSession)
		tracelog.COMPLETED_ERROR(err, sessionId, "CloneSession")
		return mongoSession, err
	}

	// Clone the master session
	mongoSession = session.mongoSession.Clone()

	tracelog.COMPLETED(sessionId, "CloneSession")
	return mongoSession, err
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:21,代码来源:mongo.go


示例13: FindRegion

// FindRegion retrieves the stations for the specified region
func FindRegion(service *services.Service, region string) (buoyStations []*buoyModels.BuoyStation, err error) {
	defer helper.CatchPanic(&err, service.UserId, "FindRegion")

	tracelog.STARTED(service.UserId, "FindRegion")

	queryMap := bson.M{"region": region}
	tracelog.TRACE(service.UserId, "FindRegion", "Query : %s", mongo.ToString(queryMap))

	buoyStations = []*buoyModels.BuoyStation{}
	err = service.DBAction(Config.Database, "buoy_stations",
		func(collection *mgo.Collection) error {
			return collection.Find(queryMap).All(&buoyStations)
		})

	if err != nil {
		tracelog.COMPLETED_ERROR(err, service.UserId, "FindRegion")
		return buoyStations, err
	}

	tracelog.COMPLETED(service.UserId, "FindRegion")
	return buoyStations, err
}
开发者ID:pmljm,项目名称:beego-mgo,代码行数:23,代码来源:buoyService.go


示例14: Execute

// Execute the MongoDB literal function
func Execute(sessionId string, mongoSession *mgo.Session, databaseName string, collectionName string, mongoCall MongoCall) (err error) {
	tracelog.STARTEDf(sessionId, "Execute", "Database[%s] Collection[%s]", databaseName, collectionName)

	// Capture the specified collection
	collection, err := GetCollection(mongoSession, databaseName, collectionName)
	if err != nil {

		tracelog.COMPLETED_ERROR(err, sessionId, "Execute")
		return err
	}

	// Execute the mongo call
	err = mongoCall(collection)
	if err != nil {
		tracelog.COMPLETED_ERROR(err, sessionId, "Execute")
		return err
	}

	tracelog.COMPLETED(sessionId, "Execute")

	return err
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:23,代码来源:mongo.go


示例15: IsTokenValid

// IsTokenValid checks whether a token is valid for a Secure Entity.
func IsTokenValid(secureEntity SecureEntity, token string) error {
	tracelog.STARTED("Utils", "IsValidToken")

	decodedToken, err := base64.StdEncoding.DecodeString(token)
	if err != nil {
		tracelog.ERRORf(err, "Utils", "Utils.IsValidToken", "Error Decoding Passed In Token, %s", token)
		return err
	}

	entityToken, tErr := secureEntity.TokenBytes()
	if tErr != nil {
		tracelog.ERRORf(tErr, "Utils", "Utils.IsValidToken", "Error Generating Token for Entity")
		return tErr
	}

	if hmac.Equal(decodedToken, entityToken) == false {
		tracelog.ERRORf(err, "Utils", "Utils.IsValidToken", "Invalid Token Comparison,Tokens Are not the same, Invalid Token, entity[%s], decoded[%s]", string(entityToken), string(decodedToken))
		return errors.New("Invalid Token")
	}

	tracelog.COMPLETED("Utils", "IsValidToken, Token Is Valid")
	return nil
}
开发者ID:swizzley,项目名称:go-common,代码行数:24,代码来源:hash.go


示例16: LoadJSON

// LoadJSON takes a json document of translations and manually
// loads them into the system
func LoadJSON(userLocale string, translationDocument string) error {
	tracelog.STARTEDf("localize", "LoadJSON", "UserLocale[%s] Length[%d]", userLocale, len(translationDocument))

	tranDocuments := []map[string]interface{}{}
	err := json.Unmarshal([]byte(translationDocument), &tranDocuments)
	if err != nil {
		tracelog.COMPLETED_ERRORf(err, "localize", "LoadJSON", "**************>")
		return err
	}

	for _, tranDocument := range tranDocuments {
		tran, err := translation.NewTranslation(tranDocument)
		if err != nil {
			tracelog.COMPLETED_ERROR(err, "localize", "LoadJSON")
			return err
		}

		i18n.AddTranslation(locale.MustNew(userLocale), tran)
	}

	tracelog.COMPLETED("localize", "LoadJSON")
	return nil
}
开发者ID:johnzan,项目名称:beego-mgo,代码行数:25,代码来源:messages.go


示例17: Startup

// Startup brings the manager to a running state
func Startup(sessionId string) (err error) {
	defer helper.CatchPanic(&err, sessionId, "Startup")

	// If the system has already been started ignore the call
	if _This != nil {
		return err
	}

	tracelog.STARTED(sessionId, "Startup")

	// Pull in the configuration
	config := mongoConfiguration{}
	err = envconfig.Process("mgo", &config)
	if err != nil {
		tracelog.COMPLETED_ERROR(err, sessionId, "Startup")
		return err
	}

	// Create the Mongo Manager
	_This = &mongoManager{
		sessions: map[string]*mongoSession{},
	}

	// Log the mongodb connection straps
	tracelog.TRACE(sessionId, "Startup", "MongoDB : Hosts[%s]", config.Hosts)
	tracelog.TRACE(sessionId, "Startup", "MongoDB : Database[%s]", config.Database)
	tracelog.TRACE(sessionId, "Startup", "MongoDB : Username[%s]", config.UserName)

	hosts := strings.Split(config.Hosts, ",")

	// Create the strong and monotonic sessions
	err = CreateSession(sessionId, "strong", MASTER_SESSION, hosts, config.Database, config.UserName, config.Password)
	err = CreateSession(sessionId, "monotonic", MONOTONIC_SESSION, hosts, config.Database, config.UserName, config.Password)

	tracelog.COMPLETED(sessionId, "Startup")
	return err
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:38,代码来源:mongo.go


示例18: FindStation

// FindStation retrieves the specified station
func FindStation(service *services.Service, stationId string) (buoyStation *buoyModels.BuoyStation, err error) {
	defer helper.CatchPanic(&err, service.UserId, "FindStation")

	tracelog.STARTED(service.UserId, "FindStation")

	// Find the specified station id
	queryMap := bson.M{"station_id": stationId}
	tracelog.TRACE(service.UserId, "FindStation", "Query : %s", mongo.ToString(queryMap))

	// Execute the query
	buoyStation = &buoyModels.BuoyStation{}
	err = service.DBAction(Config.Database, "buoy_stations",
		func(collection *mgo.Collection) error {
			return collection.Find(queryMap).One(buoyStation)
		})

	if err != nil {
		tracelog.COMPLETED_ERROR(err, service.UserId, "FindStation")
		return buoyStation, err
	}

	tracelog.COMPLETED(service.UserId, "FindStation")
	return buoyStation, err
}
开发者ID:vegansk,项目名称:beego-mgo,代码行数:25,代码来源:buoyService.go


示例19: Finish

func Finish(service *services.Service) {
	service.Finish()

	tracelog.COMPLETED(service.UserId, "Finish")
}
开发者ID:jharlap,项目名称:beego-mgo,代码行数:5,代码来源:serviceTests.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang tracelog.COMPLETED_ERROR函数代码示例发布时间:2022-05-23
下一篇:
Golang helper.CatchPanic函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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