本文整理匯總了Golang中github.com/goinggo/tracelog.CompletedError函數的典型用法代碼示例。如果您正苦於以下問題:Golang CompletedError函數的具體用法?Golang CompletedError怎麽用?Golang CompletedError使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CompletedError函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
}
示例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
}
示例3: init
func init() {
// Pull in the configuration
err := envconfig.Process("buoy", &Config)
if err != nil {
tracelog.CompletedError(err, helper.MAIN_GO_ROUTINE, "Init")
}
}
示例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
}
}
}
示例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()
}
示例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
}
示例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())
}
})
}
示例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)
}
}
}
示例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
}
示例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})
}
示例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})
}
示例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
}
示例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})
}
示例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)
}
}
示例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
}