本文整理匯總了Golang中github.com/goinggo/tracelog.STARTED函數的典型用法代碼示例。如果您正苦於以下問題:Golang STARTED函數的具體用法?Golang STARTED怎麽用?Golang STARTED使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了STARTED函數的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
func main() {
tracelog.Start(tracelog.LEVEL_TRACE)
// Init mongo
tracelog.STARTED("main", "Initializing Mongo")
err := mongo.Startup(helper.MAIN_GO_ROUTINE)
if err != nil {
tracelog.COMPLETED_ERROR(err, helper.MAIN_GO_ROUTINE, "initApp")
os.Exit(1)
}
beego.Run()
tracelog.STARTED(helper.MAIN_GO_ROUTINE, "Website Shutdown")
tracelog.Stop()
}
示例2: 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
}
示例3: 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
}
示例4: 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")
}
示例5: Decode
// Decode takes a JSON document and decodes that into a Go native object
func Decode(doc []byte, obj interface{}) error {
tracelog.STARTED("utils", "Decode")
docMap := map[string]interface{}{}
if err := json.Unmarshal(doc, &docMap); err != nil {
tracelog.ERROR(err, "utils", "Decode, Building Mapped Doc")
return err
}
return DecodeMap(docMap, obj)
}
示例6: init
// init initializes all required packages and systems
func init() {
tracelog.Start(tracelog.LEVEL_TRACE)
// Init mongo
tracelog.STARTED("main", "Initializing Mongo")
err := mongo.Startup(helper.MAIN_GO_ROUTINE)
if err != nil {
tracelog.COMPLETED_ERROR(err, helper.MAIN_GO_ROUTINE, "initTesting")
return
}
}
示例7: 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
}
示例8: IsArrayResponse
// IsArrayResponse validates if the specified JSON document
// is an array or slice
func IsArrayResponse(doc []byte) bool {
tracelog.STARTED("utils", "IsArrayResponse")
docString := string(doc)
docSlice := strings.TrimLeft(docString, " ")
if len(docSlice) > 0 && string(docSlice[0]) == "[" {
tracelog.COMPLETEDf("utils", "IsArrayReponse", "Doc is Array")
return true
}
tracelog.COMPLETEDf("utils", "IsArrayResponse", "Doc is not Array")
return false
}
示例9: 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
}
示例10: 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
}
示例11: 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
}
示例12: 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
}
示例13: 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
}