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

Golang tracelog.CompletedError函数代码示例

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

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



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

示例1: Startup

// Startup brings the manager to a running state.
func Startup(sessionID string) error {
	// If the system has already been started ignore the call.
	if singleton.sessions != nil {
		return nil
	}

	log.Started(sessionID, "Startup")

	// Pull in the configuration.
	var config mongoConfiguration
	if err := envconfig.Process("mgo", &config); err != nil {
		log.CompletedError(err, sessionID, "Startup")
		return err
	}

	// Create the Mongo Manager.
	singleton = mongoManager{
		sessions: make(map[string]mongoSession),
	}

	// Create the strong session.
	if err := CreateSession(sessionID, "strong", MasterSession, config.Url); err != nil {
		log.CompletedError(err, sessionID, "Startup")
		return err
	}

	// Create the monotonic session.
	if err := CreateSession(sessionID, "monotonic", MonotonicSession, config.Url); err != nil {
		log.CompletedError(err, sessionID, "Startup")
		return err
	}

	log.Completed(sessionID, "Startup")
	return nil
}
开发者ID:liuhong1happy,项目名称:ConsoleWindowApp,代码行数:36,代码来源:mongo.go


示例2: FindUserByName

func FindUserByName(service *services.Service, userName string) (*userModel.UserInfo, error) {
	log.Startedf(service.UserID, "FindUserByName", "userName[%s]", userName)
	var userInfo userModel.UserInfo
	f := func(collection *mgo.Collection) error {
		queryMap := bson.M{
			"$or": []bson.M{
				bson.M{"user_name": userName},
				bson.M{"user_email": userName},
				bson.M{"user_mobile": userName},
			},
		}
		log.Trace(service.UserID, "FindUserByName", "MGO : db.user_infos.find(%s).limit(1)", mongo.ToString(queryMap))
		return collection.Find(queryMap).One(&userInfo)
	}

	if err := service.DBAction(Config.Database, "user_infos", f); err != nil {
		if err != mgo.ErrNotFound {
			log.CompletedError(err, service.UserID, "FindUserByName")
			return nil, err
		}
	}

	log.Completedf(service.UserID, "FindUserByName", "userInfo%+v", &userInfo)
	return &userInfo, nil
}
开发者ID:blackcs,项目名称:ConsoleWindowApp,代码行数:25,代码来源:userService.go


示例3: init

func init() {
	// Pull in the configuration
	err := envconfig.Process("buoy", &Config)
	if err != nil {
		tracelog.CompletedError(err, helper.MAIN_GO_ROUTINE, "Init")
	}
}
开发者ID:jharlap,项目名称:beego-mgo,代码行数:7,代码来源:buoyService.go


示例4: searchDirectory

// searchDirectory recurses through the specified directory looking
// for i18n folders. If found it will load the translations files
func searchDirectory(directory string, pwd string) {
	// Read the directory
	fileInfos, err := ioutil.ReadDir(directory)
	if err != nil {
		tracelog.CompletedError(err, "localize", "searchDirectory")
		return
	}

	// Look for i18n folders
	for _, fileInfo := range fileInfos {
		if fileInfo.IsDir() == true {
			fullPath := fmt.Sprintf("%s/%s", directory, fileInfo.Name())

			// If this directory is the current directory, ignore it
			if fullPath == pwd {
				continue
			}

			// Is this an i18n folder
			if fileInfo.Name() == "i18n" {
				loadTranslationFiles(fullPath)
				continue
			}

			// Look for more sub-directories
			searchDirectory(fullPath, pwd)
			continue
		}
	}
}
开发者ID:ZloiBubr,项目名称:beego-mgo,代码行数:32,代码来源:messages.go


示例5: main

func main() {
	tracelog.Start(tracelog.LevelTrace)

	// Init mongo
	tracelog.Started("main", "Initializing Mongo")
	err := mongo.Startup(helper.MainGoRoutine)
	if err != nil {
		tracelog.CompletedError(err, helper.MainGoRoutine, "initApp")
		os.Exit(1)
	}

	// Load message strings
	localize.Init("en-US")

	SessionConfig, err := session.GetSessionConfig("session")

	tracelog.Trace("main", "SessionConfig", "Session : On[%v]", SessionConfig.On)
	tracelog.Trace("main", "SessionConfig", "Session : On[%v]", SessionConfig.Provider)
	tracelog.Trace("main", "SessionConfig", "Session : On[%v]", SessionConfig.SavePath)

	beego.SessionOn = SessionConfig.On
	beego.SessionProvider = SessionConfig.Provider
	beego.SessionSavePath = SessionConfig.SavePath

	beego.Run()

	tracelog.Completed(helper.MainGoRoutine, "Website Shutdown")
	tracelog.Stop()
}
开发者ID:blackcs,项目名称:ConsoleWindowApp,代码行数:29,代码来源:main.go


示例6: 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.CompletedError(err, service.UserId, "FindStation")
			return buoyStation, err
		}

		err = nil
	}

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


示例7: MustLoadDB

// MustLoadDB loads the database
func MustLoadDB() {
	handle.once.Do(func() {
		// Get database name
		database := ConfigEntry("Database")
		conn, err := sql.Open(ConfigEntry("Driver"), ConfigEntry("Username")+":"+ConfigEntry("Password")+"@/"+database+"?parseTime=true")
		if err != nil {
			tracelog.CompletedError(err, "MustLoadDB", "sql.Open")
			panic(err.Error())
		}

		handle.value = conn
		err = handle.value.Ping()
		if err != nil {
			tracelog.CompletedError(err, "MustLoadDB", "handle.value.Ping")
			panic(err.Error())
		}
	})
}
开发者ID:zannet,项目名称:wiki-player,代码行数:19,代码来源:db.go


示例8: UserAuth

// UserAuth checks if a session exists
func UserAuth(store *sessions.CookieStore) gin.HandlerFunc {
	return func(c *gin.Context) {
		session := c.MustGet("session").(*sessions.Session)
		if session.Values["uid"] == nil {
			tracelog.CompletedError(errSession, "UserAuth", "Checking of session uid value")
			c.Error(errSession, "No session")
			c.AbortWithStatus(401)
		}
	}
}
开发者ID:zannet,项目名称:wiki-player,代码行数:11,代码来源:userAuth.go


示例9: Startup

// Startup brings the manager to a running state.
func Startup(sessionID string) error {
	// If the system has already been started ignore the call.
	if singleton.sessions != nil {
		return nil
	}

	log.Started(sessionID, "Startup")

	// Pull in the configuration.
	var config mongoConfiguration
	if err := envconfig.Process("mgo", &config); err != nil {
		log.CompletedError(err, sessionID, "Startup")
		return err
	}

	// Create the Mongo Manager.
	singleton = mongoManager{
		sessions: make(map[string]mongoSession),
	}

	// Log the mongodb connection straps.
	log.Trace(sessionID, "Startup", "MongoDB : Hosts[%s]", config.Hosts)
	log.Trace(sessionID, "Startup", "MongoDB : Database[%s]", config.Database)
	log.Trace(sessionID, "Startup", "MongoDB : Username[%s]", config.UserName)

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

	// Create the strong session.
	if err := CreateSession(sessionID, "strong", MasterSession, hosts, config.Database, config.UserName, config.Password); err != nil {
		log.CompletedError(err, sessionID, "Startup")
		return err
	}

	// Create the monotonic session.
	if err := CreateSession(sessionID, "monotonic", MonotonicSession, hosts, config.Database, config.UserName, config.Password); err != nil {
		log.CompletedError(err, sessionID, "Startup")
		return err
	}

	log.Completed(sessionID, "Startup")
	return nil
}
开发者ID:ZloiBubr,项目名称:beego-mgo,代码行数:43,代码来源:mongo.go


示例10: Index

func (sc *Song) Index(c *gin.Context) {
	songs, err := sc.SM.GetAll()
	if err != nil {
		tracelog.CompletedError(err, "Song", "Index")
		c.JSON(500, gin.H{"message": "Something went wrong.", "status": 500})

		return
	}

	c.JSON(200, gin.H{"songs": songs})
}
开发者ID:zannet,项目名称:wiki-player,代码行数:11,代码来源:song.go


示例11: ConfirmDelete

// ConfirmDelete deletes the user
func (uc *User) ConfirmDelete(c *gin.Context) {
	// Delete user
	err := uc.UM.Delete(c.Params.ByName("nonce"))
	if err != nil {
		tracelog.CompletedError(err, "NewUser", "uc.UM.Delete")
		c.JSON(500, gin.H{"message": "Something went wrong.", "status": 500})
		return
	}

	c.JSON(200, gin.H{"message": "User deleted successfully.", "status": 200})
}
开发者ID:zannet,项目名称:wiki-player,代码行数:12,代码来源:user.go


示例12: Execute

// Execute the MongoDB literal function.
func Execute(sessionID string, mongoSession *mgo.Session, databaseName string, collectionName string, dbCall DBCall) error {
	log.Startedf(sessionID, "Execute", "Database[%s] Collection[%s]", databaseName, collectionName)

	// Capture the specified collection.
	collection := GetCollection(mongoSession, databaseName, collectionName)
	if collection == nil {
		err := fmt.Errorf("Collection %s does not exist", collectionName)
		log.CompletedError(err, sessionID, "Execute")
		return err
	}

	// Execute the MongoDB call.
	err := dbCall(collection)
	if err != nil {
		log.CompletedError(err, sessionID, "Execute")
		return err
	}

	log.Completed(sessionID, "Execute")
	return nil
}
开发者ID:phillihq,项目名称:beelike,代码行数:22,代码来源:mongo.go


示例13: Register

// Register registers the user
func (uc *User) Register(c *gin.Context) {
	var r Register
	// Bind params
	c.Bind(&r)

	// Set user data
	uc.UM.UserData.Email = r.Email
	uc.UM.UserData.Username = r.Username
	uc.UM.UserData.FirstName = r.FirstName
	uc.UM.UserData.LastName = r.LastName
	uc.UM.UserData.Hash = utils.ComputeHmac256(r.Password, utils.ConfigEntry("Salt"))
	uc.UM.UserData.AccessLevel = 10 // Figure out how to set this properly
	uc.UM.UserData.Joined = time.Now().Local()

	// Create user
	id, err := uc.UM.Create()
	if err != nil {
		tracelog.CompletedError(err, "NewUser", "uc.UM.Save")
		c.JSON(500, gin.H{"message": "Something went wrong.", "status": 500})
		return
	}

	if id == 0 {
		c.JSON(409, gin.H{"message": "Duplicate entry.", "status": 409})
		return
	}

	// Set user ID to last inserted ID
	uc.UM.UserData.Id = strconv.FormatInt(id, 10)

	// Set session
	err = uc.setSession(c)
	if err != nil {
		tracelog.CompletedError(err, "NewUser", "uc.setSession")
		c.JSON(500, gin.H{"message": "Something went wrong.", "status": 500})
		return
	}

	c.JSON(200, gin.H{"message": "Registered successfully.", "status": 200})
}
开发者ID:zannet,项目名称:wiki-player,代码行数:41,代码来源:user.go


示例14: Session

// Session attaches session to gin context
func Session(store *sessions.CookieStore) gin.HandlerFunc {
	return func(c *gin.Context) {
		session, err := store.Get(c.Request, utils.ConfigEntry("SessionName"))
		if err != nil {
			tracelog.CompletedError(err, "Session", "Getting the session")
			c.Error(err, "Failed to create session")
			c.AbortWithStatus(500)
		}

		c.Set("session", session)
		defer context.Clear(c.Request)
	}
}
开发者ID:zannet,项目名称:wiki-player,代码行数:14,代码来源:session.go


示例15: 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.CompletedError(err, sessionId, "Execute")
		return err
	}

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

	tracelog.Completed(sessionId, "Execute")

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


示例16: 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.CompletedError(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
	singleton.sessions[sessionName] = mongoSession

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


示例17: Create

// Create creates a nonce
func (nc *Nonce) Create(c *gin.Context) {
	// Get session
	session := c.MustGet("session").(*sessions.Session)

	nonce, err := nc.NM.Create(session.Values["uid"].(string))
	if err != nil {
		tracelog.CompletedError(err, "Nonce", "Create")
		c.JSON(500, gin.H{"message": "Something went wrong.", "status": 500})

		return
	}

	c.JSON(200, gin.H{"nonce": nonce})
}
开发者ID:zannet,项目名称:wiki-player,代码行数:15,代码来源:nonce.go


示例18: init

// init initializes all required packages and systems
func init() {
	//	log.Start(log.LEVEL_TRACE)

	// Init mongo
	log.Started("main", "Initializing Mongo")
	err := mongo.Startup(helper.MainGoRoutine)
	if err != nil {
		log.CompletedError(err, helper.MainGoRoutine, "initTesting")
		return
	}

	// Load message strings
	localize.Init("en-US")
}
开发者ID:blackcs,项目名称:ConsoleWindowApp,代码行数:15,代码来源:serviceTests.go


示例19: MustLoadConfig

// MustLoadConfig loads the configs and assign it to configMap
func MustLoadConfig() {
	ci.once.Do(func() {
		// Get app mode -- test/development/production
		mode := EnvConfigEntry("Mode")
		fmt.Println(mode)
		// Find the location of the config.json file
		configFilePath, err := filepath.Abs("app/configs/" + mode + ".json")

		// Open the config.json file
		file, err := os.Open(configFilePath)
		if err != nil {
			tracelog.CompletedError(err, "MustLoadConfig", "os.Open")
			panic(err.Error())
		}
		defer file.Close()

		// Read the config file
		decoder := json.NewDecoder(file)
		c := &config{}
		err = decoder.Decode(&c)
		if err != nil {
			tracelog.CompletedError(err, "MustLoadConfig", "decoder.Decode")
			panic(err.Error())
		}

		// Create a configMap object
		ci.value = configMap{ConfigMap: make(map[string]string)}

		// Assign config field:value pairs to ConfigMap
		v := reflect.ValueOf(c).Elem()
		vType := v.Type()
		for i := 0; i < v.NumField(); i++ {
			f := v.Field(i)
			ci.value.ConfigMap[vType.Field(i).Name] = f.Interface().(string)
		}
	})
}
开发者ID:zannet,项目名称:wiki-player,代码行数:38,代码来源:config.go


示例20: UserLogup

func UserLogup(service *services.Service, userInfo userModel.UserInfo) (*userModel.UserInfo, error) {
	log.Startedf(service.UserID, "UserLogup", "user[%s]", userInfo.UserName)
	f := func(collection *mgo.Collection) error {
		log.Trace(service.UserID, "UserLogup", "MGO : db.user_infos.insert(%s)", mongo.ToString(userInfo))
		return collection.Insert(&userInfo)
	}
	if err := service.DBAction(Config.Database, "user_infos", f); err != nil {
		if err != mgo.ErrNotFound {
			log.CompletedError(err, service.UserID, "UserLogup")
			return nil, err
		}
	}
	log.Completedf(service.UserID, "UserLogup", "userInfo%+v", &userInfo)
	return &userInfo, nil
}
开发者ID:blackcs,项目名称:ConsoleWindowApp,代码行数:15,代码来源:userService.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang tracelog.CompletedErrorf函数代码示例发布时间:2022-05-23
下一篇:
Golang tracelog.Completed函数代码示例发布时间: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