// Event generates a random event.
322351
func (g *EventGenerator) Event() *Event {
	active, alive := g.r.Intn(2) > 0, g.r.Intn(2) > 0
	return &Event{
		ID:              fmt.Sprintf("%d", g.r.Uint64()),
		Station:         g.g.String(6, 2000),
		UserID:          int(g.g.Uint64(100000000)) + 1,
		Timestamp:       g.g.Time(time.Date(2017, time.January, 1, 0, 0, 0, 0, time.UTC), time.Second*3).Format(time.RFC3339),
		Favorites:       g.genFavorites(),
		Items:           g.genItems(),
		Ranking:         g.genItems(),
		IfaceThing:      String(g.g.String(5, 5)),
		Velocity:        g.r.Intn(1000) + 2500,
		Active:          active,
		Alive:           alive,
		DeceasedBoolean: alive,

		Geo: g.genGeo(),
	}

}
1260692
func (e EventListener) Event(event *core.Event) {
	value := e.Factory.GetConfigurationByKey(event.Key)
	openlogging.GetLogger().Infof("config value after change %s | %s", event.Key, value)
}
293101
func event(out io.Writer) {
	event_h := readHeader("event")

	// Event is implemented by hand in wrappers.go

	// Get all the pn_event_type_t enum values
	var etypes []eventType
	enums := findEnums(event_h)
	for _, e := range enums[0].Values {
		if skipEventRe.FindStringSubmatch(e) == nil {
			etypes = append(etypes, newEventType(e))
		}
	}

	doTemplate(out, etypes, `
type EventType int
const ({{range .}}
	 E{{.Name}} EventType = C.{{.Cname}}{{end}}
)
`)

	doTemplate(out, etypes, `
func (e EventType) String() string {
	switch e {
{{range .}}
	case C.{{.Cname}}: return "{{.Name}}"{{end}}
	}
	return "Unknown"
}
`)
}
1085420
func (engine *GoEngine) Event(action Event, i interface{}) {
	if action == TEMPLATE_REFRESH_REQUESTED {
		// At this point all the templates have been passed into the
		engine.templatesByName = map[string]*GoTemplate{}
		engine.templateSet = template.New("__root__").Funcs(TemplateFuncs)
		// Check to see what should be used for case sensitivity
		engine.CaseInsensitive = Config.BoolDefault("go.template.caseinsensitive", true)
	}
}
532095
func (l *LogDebugger) Event(e *Event) {
	i := atomic.AddInt32(&l.counter, 1)
	l.logger.Printf("[%06d] %d [%6d - %s] %q (%s)\n", i, e.CollectorID, e.RequestID, e.Type, e.Values, time.Since(l.start))
}
1354183
func (e EventBuilder) ToEvent(channel, pattern string) Event {
	fields := make([]Field, len(e.fields))
	copy(fields, e.fields)

	return Event{
		fields:  fields,
		kind:    e.kind,
		channel: channel,
		pattern: pattern,
	}
}
1322192
func (e Event) String() string {
	if val, found := tostr[e]; found {
		return val
	}

	return "UNKNOWN"
}
1146688
func (ah *AirbrakeHandler) Event(logEvent *event.Event) error {
	errors := []*airbrakeError{}

	aErr := &airbrakeError{
		//TODO once sawmill/event copies the original struct, we can access the type and expose it here
		ErrType:   logEvent.Level.String(),
		Message:   logEvent.Message,
		Backtrace: newAirbrakeStack(logEvent.Stack),
	}
	errors = append(errors, aErr)

	ah.Lock()
	notice := &airbrakeNotice{
		Notifier:    &notifier,
		Errors:      errors,
		Params:      logEvent.FlatFields,
		Context:     ah.Context,
		Environment: ah.Env,
	}

	buf := &bytes.Buffer{}
	enc := json.NewEncoder(buf)
	if err := enc.Encode(notice); err != nil {
		ah.Unlock()
		return err
	}

	resp, err := http.Post(ah.AirbrakeURL.String(), "application/json", buf)
	ah.Unlock()
	if err != nil {
		return err
	}

	io.Copy(ioutil.Discard, resp.Body)
	resp.Body.Close()

	if resp.StatusCode != http.StatusCreated {
		return fmt.Errorf("unexpected status code from airbrake: %d", resp.StatusCode)
	}

	return nil
}
61973
func (e *Event) String() string {
	ret := fmt.Sprintf("(Event Type: %s", e.Tp)
	if e.TableInfo != nil {
		ret += fmt.Sprintf(", Table ID: %d, Table Name %s", e.TableInfo.ID, e.TableInfo.Name)
	}
	if e.ColumnInfo != nil {
		ret += fmt.Sprintf(", Column ID: %d, Column Name %s", e.ColumnInfo.ID, e.ColumnInfo.Name)
	}
	if e.IndexInfo != nil {
		ret += fmt.Sprintf(", Index ID: %d, Index Name %s", e.IndexInfo.ID, e.IndexInfo.Name)
	}
	return ret
}
1025052
func createEvent(event string) (windows.Handle, error) {
	ev, _ := windows.UTF16PtrFromString(event)
	sd, err := winio.SddlToSecurityDescriptor("D:P(A;;GA;;;BA)(A;;GA;;;SY)")
	if err != nil {
		return 0, errors.Wrapf(err, "failed to get security descriptor for event '%s'", event)
	}
	var sa windows.SecurityAttributes
	sa.Length = uint32(unsafe.Sizeof(sa))
	sa.InheritHandle = 1
	sa.SecurityDescriptor = uintptr(unsafe.Pointer(&sd[0]))
	h, err := windows.CreateEvent(&sa, 0, 0, ev)
	if h == 0 || err != nil {
		return 0, errors.Wrapf(err, "failed to create event '%s'", event)
	}
	return h, nil
}
852594
func (sw *SplunkHandler) Event(logEvent *event.Event) error {
	splunkURL, _ := url.Parse(sw.url.String())
	values := splunkURL.Query()
	values.Set("host", sw.Hostname)
	values.Set("source", sw.Source)
	values.Set("sourcetype", sw.SourceType)
	values.Set("index", sw.Index)
	splunkURL.RawQuery = values.Encode()
	splunkURL.Path = splunkURL.Path + "services/receivers/simple"

	sessionKey, err := sw.getSessionKey()
	if err != nil {
		return err
	}

	var templateBuffer bytes.Buffer
	sw.Template.Execute(&templateBuffer, formatter.EventFormatter(logEvent))
	eventBytes := templateBuffer.Bytes()
	eventBytes = bytes.Replace(eventBytes, []byte{'\n'}, []byte{'\r'}, -1)

	req, _ := http.NewRequest("POST", splunkURL.String(), bytes.NewReader(eventBytes))
	req.Header.Set("Authorization", "Splunk "+sessionKey)
	//req.Write(os.Stderr)
	//return nil

	resp, err := sw.client.Do(req)
	if err != nil {
		return err
	}
	resp.Body.Close()

	return nil
}
259305
func NewEvent(event interface{}, sourceURL string) *Event {
	return &Event{
		SourceURL: sourceURL,
		Event:     event,
	}
}
962663
func (a *EventCounter) Events(now time.Time, count int64) int64 {
	for {
		nsSince := now.Sub(a.startingTime).Nanoseconds()
		prevNsSinceStart := atomic.LoadInt64(&a.nsSinceStart)
		if nsSince-prevNsSinceStart >= a.eventDuration.Nanoseconds() {
			//		 Note: There is an accepted race here when we transition states that could cause us to
			//		       rarely miss an event that crosses the threshold.  This is an accepted aspect of
			//		       having a very fast non threshold event
			if atomic.CompareAndSwapInt64(&a.nsSinceStart, prevNsSinceStart, nsSince) {
				atomic.StoreInt64(&a.eventsThisPeriod, 0)
				break
			}
		} else {
			break
		}
	}
	return atomic.AddInt64(&a.eventsThisPeriod, count)
}
43277
func (g *GitHttp) event(e Event) {
	if g.EventHandler != nil {
		g.EventHandler(e)
	} else {
		fmt.Printf("EVENT: %q\n", e)
	}
}
523666
func newEvent(name string, mask uint32) Event {
	e := Event{Name: name}
	if mask&unix.NOTE_DELETE == unix.NOTE_DELETE {
		e.Op |= Remove
	}
	if mask&unix.NOTE_WRITE == unix.NOTE_WRITE {
		e.Op |= Write
	}
	if mask&unix.NOTE_RENAME == unix.NOTE_RENAME {
		e.Op |= Rename
	}
	if mask&unix.NOTE_ATTRIB == unix.NOTE_ATTRIB {
		e.Op |= Chmod
	}
	return e
}
215755
func (h *Handler) HandleEvent(e *events.Event) {
	f := fmtPool.Get().(*formatter)
	f.buffer.Reset()
	f.emitter.Reset(&f.buffer)

	f.level = "INFO"
	f.time = e.Time
	f.message = e.Message
	f.data.args = e.Args
	f.info.Source = e.Source
	f.info.Program = h.Program
	f.info.Pid = h.Pid

	if e.Debug {
		f.level = "DEBUG"
	}

	for _, a := range e.Args {
		if err, ok := a.Value.(error); ok {
			f.level = "ERROR"
			f.info.Errors = append(f.info.Errors, makeEventError(err))
		}
	}

	(objconv.Encoder{Emitter: &f.emitter}).Encode(f.value)
	f.buffer.WriteByte('\n')

	h.mutex.Lock()
	h.Output.Write(f.buffer.b)
	h.mutex.Unlock()

	f.info.Source = ""
	f.info.Errors = f.info.Errors[:0]
	fmtPool.Put(f)
}
724287
func Error(buffer Buffer, event *cue.Event) {
	if event.Error == nil {
		return
	}
	buffer.AppendString(event.Error.Error())
}