本文整理汇总了Golang中github.com/tideland/golib/logger.Errorf函数的典型用法代码示例。如果您正苦于以下问题:Golang Errorf函数的具体用法?Golang Errorf怎么用?Golang Errorf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Errorf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: startNodeMonitor
func startNodeMonitor() {
// Never do this if serf isn't set up
if !config.Config.UseSerf {
return
}
go func() {
// wait 1 minute before starting to check for nodes being up
time.Sleep(1 * time.Minute)
ticker := time.NewTicker(time.Minute)
for _ = range ticker.C {
unseen, err := node.UnseenNodes()
if err != nil {
logger.Errorf(err.Error())
continue
}
for _, n := range unseen {
logger.Infof("Haven't seen %s for a while, marking as down", n.Name)
err = n.UpdateStatus("down")
if err != nil {
logger.Errorf(err.Error())
continue
}
}
}
}()
return
}
开发者ID:theckman,项目名称:goiardi,代码行数:27,代码来源:goiardi.go
示例2: update
func (idoc *IdxDoc) update(object Indexable) {
idoc.m.Lock()
defer idoc.m.Unlock()
flattened := util.Indexify(object.Flatten())
flatText := strings.Join(flattened, "\n")
/* recover from horrific trie errors that seem to happen with really
* big values. :-/ */
defer func() {
if e := recover(); e != nil {
logger.Errorf("There was a problem creating the trie: %s", fmt.Sprintln(e))
}
}()
trie, err := gtrie.Create(flattened)
if err != nil {
logger.Errorf(err.Error())
} else {
var err error
idoc.trie, err = compressTrie(trie)
if err != nil {
panic(err)
}
idoc.docText, err = compressText(flatText)
if err != nil {
panic(err)
}
}
}
开发者ID:theckman,项目名称:goiardi,代码行数:27,代码来源:file_index.go
示例3: 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
示例4: main
func main() {
config := cachet.Config
// TODO support log path
logger.SetLogger(logger.NewTimeformatLogger(os.Stderr, "2006-01-02 15:04:05"))
logger.SetLevel(logger.LevelDebug)
logger.Infof("System: %s, API: %s", config.SystemName, config.APIUrl)
logger.Infof("Starting %d monitors", len(config.MonitorConfigs))
// initialize monitors
var allMonitors []*cachet.Monitor
for _, monconf := range config.MonitorConfigs {
err, mon := cachet.NewMonitor(&monconf)
if err == nil {
err = cachet.SyncMonitor(mon)
if err != nil {
logger.Errorf("%v", err)
}
allMonitors = append(allMonitors, mon)
} else {
logger.Errorf("Parsing monitor error, skipping: %v", err)
}
}
ticker := time.NewTicker(time.Second * time.Duration(config.CheckInterval))
for range ticker.C {
for _, m := range allMonitors {
go m.Check()
}
}
}
开发者ID:pellaeon,项目名称:cachet-monitor,代码行数:31,代码来源:main.go
示例5: 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
示例6: ClearIndex
// ClearIndex of all collections and documents
func ClearIndex() {
err := objIndex.Clear()
if err != nil {
logger.Errorf("Error clearing db for reindexing: %s", err.Error())
}
return
}
开发者ID:theckman,项目名称:goiardi,代码行数:8,代码来源:indexer.go
示例7: 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
示例8: ProcessEvent
// ProcessEvent reads, validates and emits a configuration.
func (b *configuratorBehavior) ProcessEvent(event cells.Event) error {
switch event.Topic() {
case ReadConfigurationTopic:
// Read configuration
filename, ok := event.Payload().GetString(ConfigurationFilenamePayload)
if !ok {
logger.Errorf("cannot read configuration without filename payload")
return nil
}
logger.Infof("reading configuration from %q", filename)
cfg, err := etc.ReadFile(filename)
if err != nil {
return errors.Annotate(err, ErrCannotReadConfiguration, errorMessages)
}
// If wanted then validate it.
if b.validate != nil {
err = b.validate(cfg)
if err != nil {
return errors.Annotate(err, ErrCannotValidateConfiguration, errorMessages)
}
}
// All done, emit it.
pvs := cells.PayloadValues{
ConfigurationPayload: cfg,
}
b.cell.EmitNewContext(ConfigurationTopic, pvs, event.Context())
}
return nil
}
开发者ID:tideland,项目名称:gocells,代码行数:30,代码来源:configurator.go
示例9: logCommand
// logCommand logs a command and its execution status.
func logCommand(cmd string, args []interface{}, err error, log bool) {
// Format the command for the log entry.
formatArgs := func() string {
if args == nil || len(args) == 0 {
return "(none)"
}
output := make([]string, len(args))
for i, arg := range args {
output[i] = string(valueToBytes(arg))
}
return strings.Join(output, " / ")
}
logOutput := func() string {
format := "CMD %s ARGS %s %s"
if err == nil {
return fmt.Sprintf(format, cmd, formatArgs(), "OK")
}
return fmt.Sprintf(format, cmd, formatArgs(), "ERROR "+err.Error())
}
// Log positive commands only if wanted, errors always.
if err != nil {
if errors.IsError(err, ErrServerResponse) || errors.IsError(err, ErrTimeout) {
return
}
logger.Errorf(logOutput())
} else if log {
logger.Infof(logOutput())
}
}
开发者ID:kung-foo,项目名称:golib,代码行数:30,代码来源:tools.go
示例10: checkRecovering
// checkRecovering checks if the cell may recover after a panic. It will
// signal an error and let the cell stop working if there have been 12 recoverings
// during the last minute or the behaviors Recover() signals, that it cannot
// handle the error.
func (c *cell) checkRecovering(rs loop.Recoverings) (loop.Recoverings, error) {
logger.Warningf("recovering cell %q after error: %v", c.id, rs.Last().Reason)
// Check frequency.
if rs.Frequency(c.recoveringNumber, c.recoveringDuration) {
err := errors.New(ErrRecoveredTooOften, errorMessages, rs.Last().Reason)
logger.Errorf("recovering frequency of cell %q too high", c.id)
return nil, err
}
// Try to recover.
if err := c.behavior.Recover(rs.Last().Reason); err != nil {
err := errors.Annotate(err, ErrEventRecovering, errorMessages, rs.Last().Reason)
logger.Errorf("recovering of cell %q failed: %v", c.id, err)
return nil, err
}
logger.Infof("successfully recovered cell %q", c.id)
return rs.Trim(c.recoveringNumber), nil
}
开发者ID:tideland,项目名称:gocells,代码行数:21,代码来源:cell.go
示例11: checkRecovering
// checkRecovering checks if the backend can be recovered.
func (c *Crontab) checkRecovering(rs loop.Recoverings) (loop.Recoverings, error) {
if rs.Frequency(12, time.Minute) {
logger.Errorf("crontab cannot be recovered: %v", rs.Last().Reason)
return nil, errors.New(ErrCrontabCannotBeRecovered, errorMessages, rs.Last().Reason)
}
logger.Warningf("crontab recovered: %v", rs.Last().Reason)
return rs.Trim(12), nil
}
开发者ID:jmptrader,项目名称:golib,代码行数:9,代码来源:timex.go
示例12: checkRecovering
// checkRecovering checks if the backend can be recovered.
func (b *stdBackend) checkRecovering(rs loop.Recoverings) (loop.Recoverings, error) {
if rs.Frequency(12, time.Minute) {
logger.Errorf("standard monitor cannot be recovered: %v", rs.Last().Reason)
return nil, errors.New(ErrMonitoringCannotBeRecovered, errorMessages, rs.Last().Reason)
}
logger.Warningf("standard monitor recovered: %v", rs.Last().Reason)
return rs.Trim(12), nil
}
开发者ID:postfix,项目名称:golib,代码行数:9,代码来源:standardbackend.go
示例13: NewFilterBehavior
// NewFilterBehavior creates a filter behavior based on the passed function.
// It emits every received event for which the filter function returns true.
func NewFilterBehavior(ff FilterFunc) cells.Behavior {
if ff == nil {
ff = func(id string, event cells.Event) bool {
logger.Errorf("filter processor %q used without function to handle event %v", id, event)
return true
}
}
return &filterBehavior{nil, ff}
}
开发者ID:kung-foo,项目名称:golib,代码行数:11,代码来源:filter.go
示例14: NewSimpleProcessorBehavior
// NewSimpleProcessorBehavior creates a filter behavior based on the passed function.
// Instead of an own logic and an own state it uses the passed simple processor
// function for the event processing.
func NewSimpleProcessorBehavior(spf SimpleProcessorFunc) cells.Behavior {
if spf == nil {
spf = func(cell cells.Cell, event cells.Event) error {
logger.Errorf("simple processor %q used without function to handle event %v", cell.ID(), event)
return nil
}
}
return &simpleBehavior{nil, spf}
}
开发者ID:tideland,项目名称:gocells,代码行数:12,代码来源:simple.go
示例15: stop
// stop terminates the cell.
func (c *cell) stop() error {
c.emitTimeoutTicker.Stop()
err := c.loop.Stop()
if err != nil {
logger.Errorf("cell %q terminated with error: %v", c.id, err)
} else {
logger.Infof("cell %q terminated", c.id)
}
return err
}
开发者ID:kung-foo,项目名称:golib,代码行数:11,代码来源:cell.go
示例16: jsonErrorReport
func jsonErrorReport(w http.ResponseWriter, r *http.Request, errorStr string, status int) {
logger.Infof(errorStr)
jsonError := map[string][]string{"error": []string{errorStr}}
w.WriteHeader(status)
enc := json.NewEncoder(w)
if err := enc.Encode(&jsonError); err != nil {
logger.Errorf(err.Error())
}
return
}
开发者ID:theckman,项目名称:goiardi,代码行数:10,代码来源:common.go
示例17: setSaveTicker
func setSaveTicker() {
if config.Config.FreezeData {
ds := datastore.New()
ticker := time.NewTicker(time.Second * time.Duration(config.Config.FreezeInterval))
go func() {
for _ = range ticker.C {
if config.Config.DataStoreFile != "" {
uerr := ds.Save(config.Config.DataStoreFile)
if uerr != nil {
logger.Errorf(uerr.Error())
}
}
ierr := indexer.SaveIndex()
if ierr != nil {
logger.Errorf(ierr.Error())
}
}
}()
}
}
开发者ID:theckman,项目名称:goiardi,代码行数:20,代码来源:goiardi.go
示例18: checkRecovering
// checkRecovering checks if the cell may recover after a panic. It will
// signal an error and let the cell stop working if there have been 12 recoverings
// during the last minute or the behaviors Recover() signals, that it cannot
// handle the error.
func (c *cell) checkRecovering(rs loop.Recoverings) (loop.Recoverings, error) {
logger.Errorf("recovering cell %q after error: %v", c.id, rs.Last().Reason)
// Check frequency.
if rs.Frequency(c.recoveringNumber, c.recoveringDuration) {
return nil, errors.New(ErrRecoveredTooOften, errorMessages, rs.Last().Reason)
}
// Try to recover.
if err := c.behavior.Recover(rs.Last().Reason); err != nil {
return nil, errors.Annotate(err, ErrEventRecovering, errorMessages, rs.Last().Reason)
}
return rs.Trim(c.recoveringNumber), nil
}
开发者ID:jmptrader,项目名称:golib,代码行数:16,代码来源:cell.go
示例19: 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
示例20: 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
注:本文中的github.com/tideland/golib/logger.Errorf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论