本文整理匯總了Golang中github.com/goinggo/tracelog.Startedf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Startedf函數的具體用法?Golang Startedf怎麽用?Golang Startedf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Startedf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例2: 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
}
示例3: 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
}
示例4: SaveFile
func SaveFile(service *services.Service, fileInfo fileModels.FileInfo) (*fileModels.FileInfo, error) {
log.Startedf(service.UserID, "SaveFile", "FileHash[%s]", fileInfo.FileHash)
f := func(collection *mgo.Collection) error {
log.Trace(service.UserID, "SaveFile", "MGO : db.file_infos.insert(%s)", mongo.ToString(fileInfo))
return collection.Insert(&fileInfo)
}
if err := service.DBAction(Config.Database, "file_infos", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "SaveFile")
return nil, err
}
}
log.Completedf(service.UserID, "SaveFile", "fileInfo%+v", &fileInfo)
return &fileInfo, nil
}
示例5: CloneSession
// CloneSession makes a clone of the specified session for client use.
func CloneSession(sessionID string, useSession string) (*mgo.Session, error) {
log.Startedf(sessionID, "CloneSession", "UseSession[%s]", useSession)
// Find the session object.
session := singleton.sessions[useSession]
if session.mongoSession == nil {
err := fmt.Errorf("Unable To Locate Session %s", useSession)
log.CompletedError(err, sessionID, "CloneSession")
return nil, err
}
// Clone the master session.
mongoSession := session.mongoSession.Clone()
log.Completed(sessionID, "CloneSession")
return mongoSession, nil
}
示例6: Index
// Index is the initial view for the buoy system.
func (controller *BuoyController) Index() {
region := "Gulf Of Mexico"
log.Startedf(controller.UserID, "BuoyController.Index", "Region[%s]", region)
buoyStations, err := buoyService.FindRegion(&controller.Service, region)
if err != nil {
log.CompletedErrorf(err, controller.UserID, "BuoyController.Index", "Region[%s]", region)
controller.ServeError(err)
return
}
controller.Data["Stations"] = buoyStations
controller.Layout = "shared/basic-layout.html"
controller.TplNames = "buoy/content.html"
controller.LayoutSections = map[string]string{}
controller.LayoutSections["PageHead"] = "buoy/page-head.html"
controller.LayoutSections["Header"] = "shared/header.html"
controller.LayoutSections["Modal"] = "shared/modal.html"
}
示例7: 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, EnUS)
default:
return fmt.Errorf("Unsupported Locale: %s", defaultLocale)
}
// Obtain the default translation function for use
var err error
if T, err = NewTranslation(defaultLocale, defaultLocale); err != nil {
return err
}
tracelog.Completed("localize", "Init")
return nil
}
示例8: FindRegion
// FindRegion retrieves the stations for the specified region
func FindRegion(service *services.Service, region string) ([]buoyModels.BuoyStation, error) {
log.Startedf(service.UserID, "FindRegion", "region[%s]", region)
var buoyStations []buoyModels.BuoyStation
f := func(collection *mgo.Collection) error {
queryMap := bson.M{"region": region}
log.Trace(service.UserID, "FindRegion", "Query : db.buoy_stations.find(%s)", mongo.ToString(queryMap))
return collection.Find(queryMap).All(&buoyStations)
}
if err := service.DBAction(Config.Database, "buoy_stations", f); err != nil {
log.CompletedError(err, service.UserID, "FindRegion")
return nil, err
}
log.Completedf(service.UserID, "FindRegion", "buoyStations%+v", buoyStations)
return buoyStations, nil
}
示例9: CreateSession
// CreateSession creates a connection pool for use.
func CreateSession(sessionID string, mode string, sessionName string, url string) error {
log.Startedf(sessionID, "CreateSession", "Mode[%s] Url[%s]", mode, sessionName, url)
// Create the database object
mongoSession := mongoSession{}
// Establish the master session.
var err error
mongoSession.mongoSession, err = mgo.Dial(url)
if err != nil {
log.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/github.com/finapps/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/github.com/finapps/mgo#Session.SetMode
mongoSession.mongoSession.SetMode(mgo.Monotonic, true)
}
// Have the session check for errors.
// http://godoc.org/github.com/finapps/mgo#Session.SetSafe
mongoSession.mongoSession.SetSafe(&mgo.Safe{})
// Add the database to the map.
singleton.sessions[sessionName] = mongoSession
log.Completed(sessionID, "CreateSession")
return nil
}
示例10: 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 := singleton.sessions[useSession]
if session == nil {
err = fmt.Errorf("Unable To Locate Session %s", useSession)
tracelog.CompletedError(err, sessionId, "CloneSession")
return mongoSession, err
}
// Clone the master session
mongoSession = session.mongoSession.Clone()
tracelog.Completed(sessionId, "CloneSession")
return mongoSession, err
}
示例11: FindStation
// FindStation retrieves the specified station
func FindStation(service *services.Service, stationID string) (*buoyModels.BuoyStation, error) {
log.Startedf(service.UserID, "FindStation", "stationID[%s]", stationID)
var buoyStation buoyModels.BuoyStation
//DBCall 方法
f := func(collection *mgo.Collection) error {
queryMap := bson.M{"station_id": stationID}
log.Trace(service.UserID, "FindStation", "MGO : db.buoy_stations.find(%s).limit(1)", mongo.ToString(queryMap))
return collection.Find(queryMap).One(&buoyStation)
}
if err := service.DBAction(Config.Database, "buoy_stations", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "FindStation")
return nil, err
}
}
log.Completedf(service.UserID, "FindStation", "buoyStation%+v", &buoyStation)
return &buoyStation, nil
}
示例12: FindInfo
func FindInfo(service *services.Service, userID string) (*infoModel.Information, error) {
log.Startedf(service.UserID, "FindInfo", "userID[%s]", userID)
var information infoModel.Information
f := func(collection *mgo.Collection) error {
queryMap := bson.M{"user_id": userID}
log.Trace(service.UserID, "FindInfo", "MGO : db.information.find(%s).limit(1)", mongo.ToString(queryMap))
return collection.Find(queryMap).One(&information)
}
if err := service.DBAction(Config.Database, "information", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "FindInfo")
return nil, err
}
}
log.Completedf(service.UserID, "FindInfo", "information%+v", &information)
return &information, nil
}
示例13: FindMsg
func FindMsg(service *services.Service, userID string) (*msgModel.Message, error) {
log.Startedf(service.UserID, "FindMsg", "userID[%s]", userID)
var message msgModel.Message
f := func(collection *mgo.Collection) error {
queryMap := bson.M{"user_id": userID}
log.Trace(service.UserID, "FindMsg", "MGO : db.message.find(%s).limit(1)", mongo.ToString(queryMap))
return collection.Find(queryMap).One(&message)
}
if err := service.DBAction(Config.Database, "message", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "FindMsg")
return nil, err
}
}
log.Completedf(service.UserID, "FindMsg", "message%+v", &message)
return &message, nil
}
示例14: 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
}
示例15: FindSettings
func FindSettings(service *services.Service, userID string) (*settingsModel.WinSettings, error) {
log.Startedf(service.UserID, "FindSettings", "userID[%s]", userID)
var winSettings settingsModel.WinSettings
f := func(collection *mgo.Collection) error {
queryMap := bson.M{"user_id": userID}
log.Trace(service.UserID, "FindSettings", "MGO : db.win_settings.find(%s).limit(1)", mongo.ToString(queryMap))
return collection.Find(queryMap).One(&winSettings)
}
if err := service.DBAction(Config.Database, "win_settings", f); err != nil {
if err != mgo.ErrNotFound {
log.CompletedError(err, service.UserID, "FindSettings")
return nil, err
}
}
log.Completedf(service.UserID, "FindSettings", "winSettings%+v", &winSettings)
return &winSettings, nil
}