本文整理汇总了Golang中github.com/tideland/golib/logger.Debugf函数的典型用法代码示例。如果您正苦于以下问题:Golang Debugf函数的具体用法?Golang Debugf怎么用?Golang Debugf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Debugf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestFiltering
// TestFiltering tests the filtering of the logging.
func TestFiltering(t *testing.T) {
assert := audit.NewTestingAssertion(t, true)
ownLogger := &testLogger{}
logger.SetLogger(ownLogger)
logger.SetLevel(logger.LevelDebug)
logger.SetFilter(func(level logger.LogLevel, info, msg string) bool {
return level >= logger.LevelWarning && level <= logger.LevelError
})
logger.Debugf("Debug.")
logger.Infof("Info.")
logger.Warningf("Warning.")
logger.Errorf("Error.")
logger.Criticalf("Critical.")
assert.Length(ownLogger.logs, 3)
logger.UnsetFilter()
ownLogger = &testLogger{}
logger.SetLogger(ownLogger)
logger.Debugf("Debug.")
logger.Infof("Info.")
logger.Warningf("Warning.")
logger.Errorf("Error.")
logger.Criticalf("Critical.")
assert.Length(ownLogger.logs, 5)
}
开发者ID:reborn2005,项目名称:golib,代码行数:29,代码来源:logger_test.go
示例2: DeleteHashes
// DeleteHashes deletes all the checksum hashes given from the filestore.
func DeleteHashes(fileHashes []string) {
if config.Config.UseMySQL {
deleteHashesMySQL(fileHashes)
} else if config.Config.UsePostgreSQL {
deleteHashesPostgreSQL(fileHashes)
} else {
for _, ff := range fileHashes {
delFile, err := Get(ff)
if err != nil {
logger.Debugf("Strange, we got an error trying to get %s to delete it.\n", ff)
logger.Debugf(err.Error())
} else {
_ = delFile.Delete()
}
// May be able to remove this. Check that it actually deleted
d, _ := Get(ff)
if d != nil {
logger.Debugf("Stranger and stranger, %s is still in the file store.\n", ff)
}
}
}
if config.Config.LocalFstoreDir != "" {
for _, fh := range fileHashes {
err := os.Remove(path.Join(config.Config.LocalFstoreDir, fh))
if err != nil {
logger.Errorf(err.Error())
}
}
}
}
开发者ID:theckman,项目名称:goiardi,代码行数:31,代码来源:filestore.go
示例3: GetStreamOutput
// GetStreamOutput gets all ShoveyRunStream objects associated with a ShoveyRun
// of the given output type.
func (sr *ShoveyRun) GetStreamOutput(outputType string, seq int) ([]*ShoveyRunStream, util.Gerror) {
if config.UsingDB() {
return sr.getStreamOutSQL(outputType, seq)
}
var streams []*ShoveyRunStream
ds := datastore.New()
for i := seq; ; i++ {
logger.Debugf("Getting %s", fmt.Sprintf("%s_%s_%s_%d", sr.ShoveyUUID, sr.NodeName, outputType, i))
s, found := ds.Get("shovey_run_stream", fmt.Sprintf("%s_%s_%s_%d", sr.ShoveyUUID, sr.NodeName, outputType, i))
if !found {
break
}
logger.Debugf("got a stream: %v", s)
streams = append(streams, s.(*ShoveyRunStream))
}
return streams, nil
}
开发者ID:theckman,项目名称:goiardi,代码行数:19,代码来源:shovey.go
示例4: LogEvent
// LogEvent writes an event of the action type, performed by the given actor,
// against the given object.
func LogEvent(doer actor.Actor, obj util.GoiardiObj, action string) error {
if !config.Config.LogEvents {
logger.Debugf("Not logging this event")
return nil
}
logger.Debugf("Logging event")
var actorType string
if doer.IsUser() {
actorType = "user"
} else {
actorType = "client"
}
le := new(LogInfo)
le.Action = action
le.Actor = doer
le.ActorType = actorType
le.ObjectName = obj.GetName()
le.ObjectType = reflect.TypeOf(obj).String()
le.Time = time.Now()
extInfo, err := datastore.EncodeToJSON(obj)
if err != nil {
return err
}
le.ExtendedInfo = extInfo
actorInfo, err := datastore.EncodeToJSON(doer)
if err != nil {
return err
}
le.ActorInfo = actorInfo
if config.Config.SerfEventAnnounce {
qle := make(map[string]interface{}, 4)
qle["time"] = le.Time
qle["action"] = le.Action
qle["object_type"] = le.ObjectType
qle["object_name"] = le.ObjectName
go serfin.SendEvent("log-event", qle)
}
if config.UsingDB() {
return le.writeEventSQL()
}
return le.writeEventInMem()
}
开发者ID:theckman,项目名称:goiardi,代码行数:46,代码来源:log_info.go
示例5: searchTextCollection
func (ic *IdxCollection) searchTextCollection(term string, notop bool) (map[string]Document, error) {
results := make(map[string]Document)
ic.m.RLock()
defer ic.m.RUnlock()
l := len(ic.docs)
errCh := make(chan error, l)
resCh := make(chan *searchRes, l)
for k, v := range ic.docs {
go func(k string, v *IdxDoc) {
m, err := v.TextSearch(term)
if err != nil {
errCh <- err
resCh <- nil
} else {
errCh <- nil
if (m && !notop) || (!m && notop) {
r := &searchRes{k, v}
logger.Debugf("Adding result %s to channel", k)
resCh <- r
} else {
resCh <- nil
}
}
}(k, v)
}
for i := 0; i < l; i++ {
e := <-errCh
if e != nil {
return nil, e
}
}
for i := 0; i < l; i++ {
r := <-resCh
if r != nil {
logger.Debugf("adding result")
results[r.key] = Document(r.doc)
}
}
rsafe := safeSearchResults(results)
return rsafe, nil
}
开发者ID:theckman,项目名称:goiardi,代码行数:41,代码来源:file_index.go
示例6: searchRange
func (ic *IdxCollection) searchRange(field string, start string, end string, inclusive bool) (map[string]Document, error) {
results := make(map[string]Document)
ic.m.RLock()
defer ic.m.RUnlock()
l := len(ic.docs)
errCh := make(chan error, l)
resCh := make(chan *searchRes, l)
for k, v := range ic.docs {
go func(k string, v *IdxDoc) {
m, err := v.RangeSearch(field, start, end, inclusive)
if err != nil {
errCh <- err
resCh <- nil
} else {
errCh <- nil
if m {
r := &searchRes{k, v}
logger.Debugf("Adding result %s to channel", k)
resCh <- r
} else {
resCh <- nil
}
}
}(k, v)
}
for i := 0; i < l; i++ {
e := <-errCh
if e != nil {
return nil, e
}
}
for i := 0; i < l; i++ {
r := <-resCh
if r != nil {
logger.Debugf("adding result")
results[r.key] = Document(r.doc)
}
}
rsafe := safeSearchResults(results)
return rsafe, nil
}
开发者ID:theckman,项目名称:goiardi,代码行数:41,代码来源:file_index.go
示例7: TestGoLogger
// Test logging with the go logger.
func TestGoLogger(t *testing.T) {
log.SetOutput(os.Stdout)
logger.SetLevel(logger.LevelDebug)
logger.SetLogger(logger.NewGoLogger())
logger.Debugf("Debug.")
logger.Infof("Info.")
logger.Warningf("Warning.")
logger.Errorf("Error.")
logger.Criticalf("Critical.")
}
开发者ID:kung-foo,项目名称:cellchat,代码行数:13,代码来源:logger_test.go
示例8: SendEvent
// SendEvent sends a serf event out from goiardi.
func SendEvent(eventName string, payload interface{}) {
jsonPayload, err := json.Marshal(payload)
if err != nil {
logger.Errorf(err.Error())
return
}
err = Serfer.UserEvent(eventName, jsonPayload, true)
if err != nil {
logger.Debugf(err.Error())
}
return
}
开发者ID:theckman,项目名称:goiardi,代码行数:13,代码来源:serfin.go
示例9: SendQuery
// SendQuery sends a basic, no frills query out over serf.
func SendQuery(queryName string, payload interface{}) {
jsonPayload, err := json.Marshal(payload)
if err != nil {
logger.Errorf(err.Error())
return
}
q := &serfclient.QueryParam{Name: queryName, Payload: jsonPayload}
err = Serfer.Query(q)
if err != nil {
logger.Debugf(err.Error())
}
return
}
开发者ID:theckman,项目名称:goiardi,代码行数:14,代码来源:serfin.go
示例10: TestLogLevelFiltering
// Test log level filtering.
func TestLogLevelFiltering(t *testing.T) {
assert := audit.NewTestingAssertion(t, true)
ownLogger := &testLogger{}
logger.SetLogger(ownLogger)
logger.SetLevel(logger.LevelDebug)
logger.Debugf("Debug.")
logger.Infof("Info.")
logger.Warningf("Warning.")
logger.Errorf("Error.")
logger.Criticalf("Critical.")
assert.Length(ownLogger.logs, 5)
ownLogger = &testLogger{}
logger.SetLogger(ownLogger)
logger.SetLevel(logger.LevelError)
logger.Debugf("Debug.")
logger.Infof("Info.")
logger.Warningf("Warning.")
logger.Errorf("Error.")
logger.Criticalf("Critical.")
assert.Length(ownLogger.logs, 2)
}
开发者ID:kung-foo,项目名称:cellchat,代码行数:24,代码来源:logger_test.go
示例11: startEventMonitor
func startEventMonitor(sc *serfclient.RPCClient, errch chan<- error) {
ch := make(chan map[string]interface{}, 10)
sh, err := sc.Stream("*", ch)
if err != nil {
errch <- err
return
}
errch <- nil
defer sc.Stop(sh)
// watch the events and queries
for e := range ch {
logger.Debugf("Got an event: %v", e)
eName, _ := e["Name"]
switch eName {
case "node_status":
jsonPayload := make(map[string]string)
err = json.Unmarshal(e["Payload"].([]byte), &jsonPayload)
if err != nil {
logger.Errorf(err.Error())
continue
}
n, _ := node.Get(jsonPayload["node"])
if n == nil {
logger.Errorf("No node %s", jsonPayload["node"])
continue
}
err = n.UpdateStatus(jsonPayload["status"])
if err != nil {
logger.Errorf(err.Error())
continue
}
r := map[string]string{"response": "ok"}
response, _ := json.Marshal(r)
var id uint64
switch t := e["ID"].(type) {
case int64:
id = uint64(t)
case uint64:
id = t
default:
logger.Errorf("node_status ID %v type %T not int64 or uint64", e["ID"], e["ID"])
continue
}
sc.Respond(id, response)
}
}
return
}
开发者ID:theckman,项目名称:goiardi,代码行数:49,代码来源:goiardi.go
示例12: TestSysLogger
// Test logging with the syslogger.
func TestSysLogger(t *testing.T) {
assert := audit.NewTestingAssertion(t, true)
logger.SetLevel(logger.LevelDebug)
sl, err := logger.NewSysLogger("GOAS")
assert.Nil(err)
logger.SetLogger(sl)
logger.Debugf("Debug.")
logger.Infof("Info.")
logger.Warningf("Warning.")
logger.Errorf("Error.")
logger.Criticalf("Critical.")
}
开发者ID:kung-foo,项目名称:cellchat,代码行数:16,代码来源:logger_test.go
示例13: execute
func (sq *SolrQuery) execute() (map[string]indexer.Document, error) {
s := sq.queryChain
curOp := OpNotAnOp
for s != nil {
var r map[string]indexer.Document
var err error
switch c := s.(type) {
case *SubQuery:
_ = c
newq, nend, nerr := extractSubQuery(s)
if nerr != nil {
return nil, err
}
s = nend
var d map[string]indexer.Document
if curOp == OpBinAnd {
d = sq.docs
} else {
d = make(map[string]indexer.Document)
}
nsq := &SolrQuery{queryChain: newq, idxName: sq.idxName, docs: d}
r, err = nsq.execute()
default:
if curOp == OpBinAnd {
r, err = s.SearchResults(sq.docs)
} else {
r, err = s.SearchIndex(sq.idxName)
}
}
if err != nil {
return nil, err
}
if len(sq.docs) == 0 || curOp == OpBinAnd { // nothing in place yet
sq.docs = r
} else if curOp == OpBinOr {
for k, v := range r {
sq.docs[k] = v
}
} else {
logger.Debugf("Somehow we got to what should have been an impossible state with search")
}
curOp = s.Op()
s = s.Next()
}
return sq.docs, nil
}
开发者ID:theckman,项目名称:goiardi,代码行数:47,代码来源:search.go
示例14: AllFilestores
// AllFilestores returns all file checksums and their contents, for exporting.
func AllFilestores() []*FileStore {
var filestores []*FileStore
if config.UsingDB() {
filestores = allFilestoresSQL()
} else {
fileList := GetList()
for _, f := range fileList {
fl, err := Get(f)
if err != nil {
logger.Debugf("File checksum %s was in the list of files, but wasn't found when fetched. Continuing.", f)
continue
}
filestores = append(filestores, fl)
}
}
return filestores
}
开发者ID:theckman,项目名称:goiardi,代码行数:18,代码来源:filestore.go
示例15: setLogEventPurgeTicker
func setLogEventPurgeTicker() {
if config.Config.LogEventKeep != 0 {
ticker := time.NewTicker(time.Second * time.Duration(60))
go func() {
for _ = range ticker.C {
les, _ := loginfo.GetLogInfos(nil, 0, 1)
if len(les) != 0 {
p, err := loginfo.PurgeLogInfos(les[0].ID - config.Config.LogEventKeep)
if err != nil {
logger.Errorf(err.Error())
}
logger.Debugf("Purged %d events automatically", p)
}
}
}()
}
}
开发者ID:theckman,项目名称:goiardi,代码行数:17,代码来源:goiardi.go
示例16: deleteHashesPostgreSQL
func deleteHashesPostgreSQL(fileHashes []string) {
if len(fileHashes) == 0 {
return // nothing to do
}
tx, err := datastore.Dbh.Begin()
if err != nil {
log.Fatal(err)
}
deleteQuery := "DELETE FROM goiardi.file_checksums WHERE checksum = ANY($1::varchar(32)[])"
_, err = tx.Exec(deleteQuery, "{"+strings.Join(fileHashes, ",")+"}")
if err != nil && err != sql.ErrNoRows {
logger.Debugf("Error %s trying to delete hashes", err.Error())
tx.Rollback()
return
}
tx.Commit()
return
}
开发者ID:theckman,项目名称:goiardi,代码行数:18,代码来源:postgres_funcs.go
示例17: AddStreamOutput
// AddStreamOutput adds a chunk of output from the job to the output list on the
// server stored in the ShoveyRunStream objects.
func (sr *ShoveyRun) AddStreamOutput(output string, outputType string, seq int, isLast bool) util.Gerror {
if config.UsingDB() {
return sr.addStreamOutSQL(output, outputType, seq, isLast)
}
stream := &ShoveyRunStream{ShoveyUUID: sr.ShoveyUUID, NodeName: sr.NodeName, Seq: seq, OutputType: outputType, Output: output, IsLast: isLast, CreatedAt: time.Now()}
ds := datastore.New()
streamKey := fmt.Sprintf("%s_%s_%s_%d", sr.ShoveyUUID, sr.NodeName, outputType, seq)
logger.Debugf("Setting %s", streamKey)
_, found := ds.Get("shovey_run_stream", streamKey)
if found {
err := util.Errorf("sequence %d for %s - %s already exists", seq, sr.ShoveyUUID, sr.NodeName)
err.SetStatus(http.StatusConflict)
return err
}
ds.Set("shovey_run_stream", streamKey, stream)
return nil
}
开发者ID:theckman,项目名称:goiardi,代码行数:20,代码来源:shovey.go
示例18: AllCookbooks
// AllCookbooks returns all the cookbooks that have been uploaded to this server.
func AllCookbooks() (cookbooks []*Cookbook) {
if config.UsingDB() {
cookbooks = allCookbooksSQL()
for _, c := range cookbooks {
// populate the versions hash
c.sortedVersions()
}
} else {
cookbookList := GetList()
for _, c := range cookbookList {
cb, err := Get(c)
if err != nil {
logger.Debugf("Curious. Cookbook %s was in the cookbook list, but wasn't found when fetched. Continuing.", c)
continue
}
cookbooks = append(cookbooks, cb)
}
}
return cookbooks
}
开发者ID:theckman,项目名称:goiardi,代码行数:21,代码来源:cookbook.go
示例19: checkCompleted
func (s *Shovey) checkCompleted() {
if config.UsingDB() {
s.checkCompletedSQL()
return
}
srs, err := s.GetNodeRuns()
if err != nil {
logger.Debugf("Something went wrong checking for job completion: %s", err.Error())
return
}
c := 0
for _, sr := range srs {
if sr.Status == "invalid" || sr.Status == "succeeded" || sr.Status == "failed" || sr.Status == "down" || sr.Status == "nacked" || sr.Status == "cancelled" {
c++
}
}
if c == len(s.NodeNames) {
s.Status = "complete"
s.save()
}
}
开发者ID:theckman,项目名称:goiardi,代码行数:21,代码来源:shovey.go
示例20: deleteHashesMySQL
func deleteHashesMySQL(fileHashes []string) {
if len(fileHashes) == 0 {
return // nothing to do
}
tx, err := datastore.Dbh.Begin()
if err != nil {
log.Fatal(err)
}
deleteQuery := "DELETE FROM file_checksums WHERE checksum IN(?" + strings.Repeat(",?", len(fileHashes)-1) + ")"
delArgs := make([]interface{}, len(fileHashes))
for i, v := range fileHashes {
delArgs[i] = v
}
_, err = tx.Exec(deleteQuery, delArgs...)
if err != nil && err != sql.ErrNoRows {
logger.Debugf("Error %s trying to delete hashes", err.Error())
tx.Rollback()
return
}
tx.Commit()
return
}
开发者ID:theckman,项目名称:goiardi,代码行数:22,代码来源:mysql_funcs.go
注:本文中的github.com/tideland/golib/logger.Debugf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论