当前位置: 首页>>代码示例>>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;未经允许,请勿转载。