本文整理汇总了Golang中github.com/tideland/golib/logger.Debugf函数的典型用法代码示例。如果您正苦于以下问题:Golang Debugf函数的具体用法?Golang Debugf怎么用?Golang Debugf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Debugf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
示例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())
}
}
}
}
示例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
}
示例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()
}
示例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
}
示例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
}
示例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.")
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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.")
}
示例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
}
示例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
}
示例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)
}
}
}()
}
}