當前位置: 首頁>>代碼示例>>Golang>>正文


Golang core.LogMessage類代碼示例

本文整理匯總了Golang中github.com/chatoooo/logoon/core.LogMessage的典型用法代碼示例。如果您正苦於以下問題:Golang LogMessage類的具體用法?Golang LogMessage怎麽用?Golang LogMessage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LogMessage類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: TestFormatterTagged

func TestFormatterTagged(t *testing.T) {
	assert := assert.New(t)

	formatter := new(StandardSinkFormatter)
	formatter.SetFormat("[%time%] [%severity%] - %message% (%tags%)")
	var msg core.LogMessage = core.CreateTaggedLogMessage("DEBUG", "test", []string{"A", "B"})

	output := formatter.GetFormattedMessage(msg)
	expected := fmt.Sprintf("[%s] [%s] - %s (%s)", msg.Time().Format(time.RFC3339), "DEBUG", "test", "A,B")

	assert.EqualValues(expected, output)
}
開發者ID:chatoooo,項目名稱:logoon,代碼行數:12,代碼來源:formatter_test.go

示例2: TestFormatterNewLines

func TestFormatterNewLines(t *testing.T) {
	assert := assert.New(t)

	formatter := new(StandardSinkFormatter)
	formatter.SetFormat("[%time%] [%severity%] - %message%")
	var msg core.LogMessage = core.CreateBasicLogMessage("DEBUG", "test\ntest")

	output := formatter.GetFormattedMessage(msg)
	expected := fmt.Sprintf("[%s] [%s] - %s", msg.Time().Format(time.RFC3339), "DEBUG", "test\n\ttest")

	assert.EqualValues(expected, output)
}
開發者ID:chatoooo,項目名稱:logoon,代碼行數:12,代碼來源:formatter_test.go

示例3: TestFormatterSpecialDateFormat

func TestFormatterSpecialDateFormat(t *testing.T) {
	assert := assert.New(t)

	formatter := new(StandardSinkFormatter)
	formatter.SetFormat("[%time(2006-02-01 15:03:04.000)%] [%severity%] - %message%")
	var msg core.LogMessage = core.CreateBasicLogMessage("DEBUG", "test")

	output := formatter.GetFormattedMessage(msg)
	expected := fmt.Sprintf("[%s] [%s] - %s", msg.Time().Format("2006-02-01 15:03:04.000"), "DEBUG", "test")

	assert.EqualValues(expected, output)
}
開發者ID:chatoooo,項目名稱:logoon,代碼行數:12,代碼來源:formatter_test.go

示例4: shouldTags

func (this *StandardSinkFilter) shouldTags(msg core.LogMessage) bool {
	if this.filter.Tags != nil && len(this.filter.Tags) > 0 {
		msgTags := msg.Tags()
		for _, filterTag := range this.filter.Tags {
			for _, messageTag := range msgTags {
				if filterTag == messageTag {
					return true
				}
			}
		}
		return false
	}
	return true
}
開發者ID:chatoooo,項目名稱:logoon,代碼行數:14,代碼來源:filter.go

示例5: GetFormattedMessage

func (this *StandardSinkFormatter) GetFormattedMessage(msg core.LogMessage) string {
	var b bytes.Buffer
	this.compiledTemplate.Execute(
		&b,
		map[string]interface{}{
			"time":     msg.Time().Format(this.timeFormat),
			"severity": msg.Severity(),
			"message":  strings.Replace(msg.Message(), "\n", "\n\t", -1),
			"tags":     strings.Join(msg.Tags(), ","),
		},
	)
	return b.String()
}
開發者ID:chatoooo,項目名稱:logoon,代碼行數:13,代碼來源:formatter.go

示例6: shouldSeverity

func (this *StandardSinkFilter) shouldSeverity(msg core.LogMessage) bool {
	var result bool
	switch this.filter.Severity.CmpOp {
	case core.FILTER_CMP_NONE:
		result = true
	case core.FILTER_CMP_GE:
		result = this.severityComparator.ge(msg.Severity(), this.filter.Severity.Level)
	case core.FILTER_CMP_EQ:
		result = this.severityComparator.eq(msg.Severity(), this.filter.Severity.Level)
	case core.FILTER_CMP_LT:
		result = this.severityComparator.lt(msg.Severity(), this.filter.Severity.Level)
	case core.FILTER_CMP_GT:
		result = this.severityComparator.gt(msg.Severity(), this.filter.Severity.Level)
	}
	return result
}
開發者ID:chatoooo,項目名稱:logoon,代碼行數:16,代碼來源:filter.go


注:本文中的github.com/chatoooo/logoon/core.LogMessage類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。