// Fire is invoked by logrus and sends log data to Application Insights.
492573
func (hook *AppInsightsHook) Fire(entry *logrus.Entry) error {
	if !hook.async {
		return hook.fire(entry)
	}
	// async - fire and forget
	go hook.fire(entry)
	return nil
}
716794
func (l *IoLogger) Log(data Data) error {
	line := fmt.Sprintf("%s\n", BuildLog(data, l.AddTime))
	_, err := l.stream.Write([]byte(line))
	return err
}
1138288
func (l Logger) logFail(format string, a ...interface{}) {
	l.Crit(fmt.Sprintf("[failed]   %s", format), a...)
}
1222172
func (hook *MailAuthHook) Fire(entry *logrus.Entry) error {
	auth := smtp.PlainAuth("", hook.Username, hook.Password, hook.Host)

	message := createMessage(entry, hook.AppName)

	// Connect to the server, authenticate, set the sender and recipient,
	// and send the email all in one step.
	err := smtp.SendMail(
		hook.Host+":"+strconv.Itoa(hook.Port),
		auth,
		hook.From.Address,
		[]string{hook.To.Address},
		message.Bytes(),
	)
	if err != nil {
		return err
	}
	return nil
}
361193
func (e *Event) Fire(params *UserEvent, q *WriteOptions) (string, *WriteMeta, error) {
	r := e.c.newRequest("PUT", "/v1/event/fire/"+params.Name)
	r.setWriteOptions(q)
	if params.NodeFilter != "" {
		r.params.Set("node", params.NodeFilter)
	}
	if params.ServiceFilter != "" {
		r.params.Set("service", params.ServiceFilter)
	}
	if params.TagFilter != "" {
		r.params.Set("tag", params.TagFilter)
	}
	if params.Payload != nil {
		r.body = bytes.NewReader(params.Payload)
	}

	rtt, resp, err := requireOK(e.c.doRequest(r))
	if err != nil {
		return "", nil, err
	}
	defer resp.Body.Close()

	wm := &WriteMeta{RequestTime: rtt}
	var out UserEvent
	if err := decodeBody(resp, &out); err != nil {
		return "", nil, err
	}
	return out.ID, wm, nil
}
30476
func (j *FormatWriterJSON) Emit(logger *Logger, level int, message string, extra Map) {
	sb := bufPool.Get()
	defer bufPool.Put(sb)

	flags := logger.Flags()

	sb.WriteByte('{')
	// if time is being logged, handle time as soon as possible
	if flags&(Ltimestamp|Ltai64n) != 0 {
		t := time.Now()
		sb.WriteString(`"time": "`)
		if flags&Ltai64n != 0 {
			writeTimeTAI64N(sb, &t, flags)
		} else {
			writeTime(sb, &t, flags)
		}
		sb.WriteString(`", `)
	}

	if flags&Llevel != 0 {
		sb.WriteString(`"level": "`)
		switch level {
		case -1:
			sb.WriteByte('D')
		case 1:
			sb.WriteByte('F')
		default:
			sb.WriteByte('I')
		}
		sb.WriteString(`", `)
	}

	if flags&(Lshortfile|Llongfile) != 0 {
		_, file, line, ok := runtime.Caller(3)
		if !ok {
			file = "???"
			line = 0
		}

		if flags&Lshortfile != 0 {
			short := file
			for i := len(file) - 1; i > 0; i-- {
				if file[i] == '/' {
					short = file[i+1:]
					break
				}
			}
			file = short
		}

		sb.WriteString(`"caller": "`)
		sb.WriteString(file)
		sb.WriteByte(':')
		sb.AppendIntWidth(line, 0)
		sb.WriteString(`", `)
	}

	sb.WriteString(`"msg": "`)
	encodeStringJSON(sb, message)
	sb.WriteByte('"')

	if extra != nil && len(extra) > 0 {
		sb.WriteString(`, "extra": {`)
		encodeLogMapJSON(sb, extra)
		sb.WriteByte('}')
	}

	sb.WriteByte('}')
	sb.WriteByte('\n')
	sb.WriteTo(logger)
}
267598
func (sh *Hook) Fire(e *logrus.Entry) error {
	if sh.limiter != nil && !sh.limiter.Allow() {
		// We've hit the configured limit, just ignore.
		return nil
	}

	m := sh.Message
	a := sh.Attachment
	m.AddAttachment(&a)
	a.Fallback = e.Message
	a.Color = sh.LevelColors[e.Level.String()]
	if a.Color == "" {
		a.Color = sh.UnknownColor
	}
	a.Text = e.Message
	for k, v := range e.Data {
		a.NewField(k, fmt.Sprint(v))
	}

	if sh.Async {
		go m.Send(sh.client)
		return nil
	}

	_, err := m.Send(sh.client)
	return err
}
754038
func (l *LogWriter) Write(p []byte) (n int, err error) {
	l.Lock()
	defer l.Unlock()

	// Strip off newlines at the end if there are any since we store
	// individual log lines in the agent.
	n = len(p)
	if p[n-1] == '\n' {
		p = p[:n-1]
	}

	l.logs[l.index] = string(p)
	l.index = (l.index + 1) % len(l.logs)

	for lh := range l.handlers {
		lh.HandleLog(string(p))
	}
	return
}
1055659
func (p *SLSHook) Fire(entry *logrus.Entry) (err error) {

	storeName := p.Config.Store

	if len(p.Config.StoreField) > 0 {
		if specStoreName, ok := entry.Data[p.Config.StoreField].(string); ok {
			storeName = specStoreName
		}
	}

	store, storeExist := p.mapStores.Load(storeName)
	if !storeExist {

		newStore, newStoreErr := sls.NewLogStore(storeName, p.project)
		if newStoreErr != nil {
			return newStoreErr
		}
		store, _ = p.mapStores.LoadOrStore(storeName, newStore)
	}

	ignoreToSend := map[string]bool{}

	ignoreToSend[p.Config.Store] = true

	logStore, ok := store.(*sls.LogStore)
	if !ok {
		err = fmt.Errorf("could not convert %s into *sls.LogStore in log store maps", storeName)
		return
	}

	slsLog := &sls.Log{Time: proto.Uint32(uint32(entry.Time.Unix()))}

	var strCtx string

	if len(p.Config.ContextField) > 0 {
		if ctxData, exist := entry.Data[p.Config.ContextField]; exist {

			if ctx, ok := ctxData.(string); ok {
				strCtx = ctx
			} else {
				jsonData, errJson := json.Marshal(ctxData)
				if errJson != nil {
					return errJson
				}

				strCtx = string(jsonData)
			}

			ignoreToSend[p.Config.ContextField] = true

			slsLog.Contents = append(slsLog.Contents,
				&sls.LogContent{
					Key:   proto.String(p.Config.ContextField),
					Value: proto.String(strCtx),
				})

		}
	}

	topic := proto.String(fieldToString(entry, p.Config.TopicField))
	source := proto.String(fieldToString(entry, p.Config.SourceField))

	ignoreToSend[p.Config.TopicField] = true
	ignoreToSend[p.Config.SourceField] = true

	if len(entry.Data) > 0 {
		for k, v := range entry.Data {

			if ignoreToSend[k] {
				continue
			}

			content := &sls.LogContent{
				Key:   proto.String(k),
				Value: proto.String(fmt.Sprintf("%v", v)),
			}

			slsLog.Contents = append(slsLog.Contents, content)
		}
	}

	slsLog.Contents = append(slsLog.Contents,
		&sls.LogContent{
			Key:   proto.String("message"),
			Value: proto.String(entry.Message),
		})

	slsLog.Contents = append(slsLog.Contents,
		&sls.LogContent{
			Key:   proto.String("log_level"),
			Value: proto.String(entry.Level.String()),
		})

	var slsTags []*sls.LogTag

	if len(p.Config.TagsField) > 0 {
		logrusTags, ok := entry.Data[p.Config.TagsField].(map[string]string)

		if ok {
			for k, v := range logrusTags {
				slsTags = append(slsTags,
					&sls.LogTag{
						Key:   proto.String(k),
						Value: proto.String(v),
					})
			}
		}
	}

	logGroup := &sls.LogGroup{
		Topic:   topic,
		Source:  source,
		Logs:    []*sls.Log{slsLog},
		LogTags: slsTags,
	}

	if p.Config.Async {
		go logStore.PutLogs(logGroup)
		return
	}

	err = logStore.PutLogs(logGroup)

	return
}
870484
func (stats *LogStats) Send() {
	stats.EndTime = time.Now()
	QueryLogger.Send(stats)
}
1242796
func (p *BearyChatHook) Fire(e *logrus.Entry) (err error) {
	color := ""
	switch e.Level {
	case logrus.DebugLevel:
		color = "#FDFEFE"
	case logrus.InfoLevel:
		color = "#5DADE2"
	case logrus.ErrorLevel, logrus.FatalLevel, logrus.PanicLevel:
		color = "#FF0000"
	default:
		color = "#FFFF00"
	}

	req := &bearychat.Message{
		Text:     e.Message,
		Markdown: p.Markdown,
		Channel:  p.Channel,
		User:     p.User,
	}

	var attachs []bearychat.Attachment

	if len(e.Data) > 0 {

		for k, v := range e.Data {
			attach := bearychat.Attachment{}

			attach.Title = k
			attach.Text = fmt.Sprint(v)
			attach.Color = color

			attachs = append(attachs, attach)
		}
	}

	req.Attachments = attachs

	if p.Async {
		go p.cli.Send(p.Url, req)
		return
	}

	_, err = p.cli.Send(p.Url, req)
	return
}
1084177
func (p *PackageLogger) Logf(l LogLevel, format string, args ...interface{}) {
	p.internalLog(calldepth, l, fmt.Sprintf(format, args...))
}
539561
func (e *Event) Fire() bool {
	ret := false
	e.o.Do(func() {
		atomic.StoreInt32(&e.fired, 1)
		close(e.c)
		ret = true
	})
	return ret
}
1192339
func (i *interruptListener) FireNow() {
	i.mu.Lock()
	for _, f := range i.onInterrupt {
		f()
	}
	i.onInterrupt = i.onInterrupt[0:0]
	i.mu.Unlock()
}
1264749
func (srv *StreamService) Firehose(params *StreamFirehoseParams) (*Stream, error) {
	req, err := srv.public.New().Get("firehose.json").QueryStruct(params).Request()
	if err != nil {
		return nil, err
	}
	return newStream(srv.client, req), nil
}
799088
func (c *Consumer) Logf(msg string, args ...interface{}) {
	c.Infof(msg, args...)
}
494974
func Logf(level LogLevelType, format string, args ...interface{}) {
	root.Logf(level, format, args...)
}