本文整理匯總了Golang中github.com/mozilla-services/heka/pipeline.FilterRunner.LogMessage方法的典型用法代碼示例。如果您正苦於以下問題:Golang FilterRunner.LogMessage方法的具體用法?Golang FilterRunner.LogMessage怎麽用?Golang FilterRunner.LogMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mozilla-services/heka/pipeline.FilterRunner
的用法示例。
在下文中一共展示了FilterRunner.LogMessage方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: restoreSandboxes
// On Heka restarts this function reloads all previously running SandboxFilters
// using the script, configuration, and preservation files in the working
// directory.
func (this *SandboxManagerFilter) restoreSandboxes(fr pipeline.FilterRunner, h pipeline.PluginHelper, dir string) {
glob := fmt.Sprintf("%s-*.toml", getNormalizedName(fr.Name()))
if matches, err := filepath.Glob(filepath.Join(dir, glob)); err == nil {
for _, fn := range matches {
var configFile pipeline.ConfigFile
if _, err = toml.DecodeFile(fn, &configFile); err != nil {
fr.LogError(fmt.Errorf("restoreSandboxes failed: %s\n", err))
continue
} else {
for _, conf := range configFile {
var runner pipeline.FilterRunner
name := path.Base(fn[:len(fn)-5])
fr.LogMessage(fmt.Sprintf("Loading: %s", name))
runner, err = this.createRunner(dir, name, conf)
if err != nil {
fr.LogError(fmt.Errorf("createRunner failed: %s\n", err.Error()))
removeAll(dir, fmt.Sprintf("%s.*", name))
break
}
err = h.PipelineConfig().AddFilterRunner(runner)
if err != nil {
fr.LogError(err)
} else {
atomic.AddInt32(&this.currentFilters, 1)
}
break // only interested in the first item
}
}
}
}
}
示例2: Run
func (f *UptimeFilter) Run(runner pipeline.FilterRunner, helper pipeline.PluginHelper) (err error) {
var (
pack *pipeline.PipelinePack
payload string
)
inChan := runner.InChan()
for pack = range inChan {
payload = pack.Message.GetPayload()
runner.LogMessage("Payload: " + payload)
if f.hours == nil {
f.hours = make(map[int64]bool)
}
var epoch int64 = f.GetEpoch(payload)
f.startHour, f.endHour = f.FigureOutStartAndEndHour(epoch)
if !f.hours[f.startHour] {
f.InitFilterForStartHour(f.startHour, payload)
} else {
f.CalculateUptimeFor(f.startHour, f.endHour)
// f.hours[&f.startHour] = false
log.Printf("Length of map: &d", len(f.hours))
}
log.Printf("Start hour: %d", f.startHour)
log.Printf("End hour: %d", f.endHour)
log.Printf("EPOCH: %d", epoch)
pack.Recycle()
}
return
}
示例3: loadSandbox
// Parses a Heka message and extracts the information necessary to start a new
// SandboxFilter
func (this *SandboxManagerFilter) loadSandbox(fr pipeline.FilterRunner,
h pipeline.PluginHelper, dir string, msg *message.Message) (err error) {
fv, _ := msg.GetFieldValue("config")
if config, ok := fv.(string); ok {
var configFile pipeline.ConfigFile
if _, err = toml.Decode(config, &configFile); err != nil {
return fmt.Errorf("loadSandbox failed: %s\n", err)
} else {
for name, conf := range configFile {
name = getSandboxName(fr.Name(), name)
if _, ok := h.Filter(name); ok {
// todo support reload
return fmt.Errorf("loadSandbox failed: %s is already running", name)
}
fr.LogMessage(fmt.Sprintf("Loading: %s", name))
confFile := filepath.Join(dir, fmt.Sprintf("%s.toml", name))
err = ioutil.WriteFile(confFile, []byte(config), 0600)
if err != nil {
return
}
var sbc SandboxConfig
if err = toml.PrimitiveDecode(conf, &sbc); err != nil {
return fmt.Errorf("loadSandbox failed: %s\n", err)
}
scriptFile := filepath.Join(dir, fmt.Sprintf("%s.%s", name, sbc.ScriptType))
err = ioutil.WriteFile(scriptFile, []byte(msg.GetPayload()), 0600)
if err != nil {
removeAll(dir, fmt.Sprintf("%s.*", name))
return
}
// check/clear the old state preservation file
// this avoids issues with changes to the data model since the last load
// and prevents holes in the graph from looking like anomalies
os.Remove(filepath.Join(pipeline.PrependBaseDir(DATA_DIR), name+DATA_EXT))
var runner pipeline.FilterRunner
runner, err = this.createRunner(dir, name, conf)
if err != nil {
removeAll(dir, fmt.Sprintf("%s.*", name))
return
}
err = h.PipelineConfig().AddFilterRunner(runner)
if err == nil {
this.currentFilters++
}
break // only interested in the first item
}
}
}
return
}
示例4: loadSandbox
// Parses a Heka message and extracts the information necessary to start a new
// SandboxFilter
func (this *SandboxManagerFilter) loadSandbox(fr pipeline.FilterRunner,
h pipeline.PluginHelper, dir string, msg *message.Message) (err error) {
fv, _ := msg.GetFieldValue("config")
if config, ok := fv.(string); ok {
var configFile pipeline.ConfigFile
if _, err = toml.Decode(config, &configFile); err != nil {
return fmt.Errorf("loadSandbox failed: %s\n", err)
}
for name, conf := range configFile {
name = getSandboxName(fr.Name(), name)
if _, ok := h.Filter(name); ok {
// todo support reload
return fmt.Errorf("loadSandbox failed: %s is already running", name)
}
fr.LogMessage(fmt.Sprintf("Loading: %s", name))
confFile := filepath.Join(dir, fmt.Sprintf("%s.toml", name))
err = ioutil.WriteFile(confFile, []byte(config), 0600)
if err != nil {
return
}
var sbc SandboxConfig
// Default, will get overwritten if necessary
sbc.ScriptType = "lua"
if err = toml.PrimitiveDecode(conf, &sbc); err != nil {
return fmt.Errorf("loadSandbox failed: %s\n", err)
}
scriptFile := filepath.Join(dir, fmt.Sprintf("%s.%s", name, sbc.ScriptType))
err = ioutil.WriteFile(scriptFile, []byte(msg.GetPayload()), 0600)
if err != nil {
removeAll(dir, fmt.Sprintf("%s.*", name))
return
}
var runner pipeline.FilterRunner
runner, err = this.createRunner(dir, name, conf)
if err != nil {
removeAll(dir, fmt.Sprintf("%s.*", name))
return
}
err = this.pConfig.AddFilterRunner(runner)
if err == nil {
atomic.AddInt32(&this.currentFilters, 1)
}
break // only interested in the first item
}
}
return
}