当前位置: 首页>>代码示例>>Golang>>正文


Golang message.NewLinesMessage函数代码示例

本文整理汇总了Golang中github.com/tychoish/grip/message.NewLinesMessage函数的典型用法代码示例。如果您正苦于以下问题:Golang NewLinesMessage函数的具体用法?Golang NewLinesMessage怎么用?Golang NewLinesMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewLinesMessage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestConditionalSend

func (s *GripInternalSuite) TestConditionalSend() {
	// because sink is an internal type (implementation of
	// sender,) and "GetMessage" isn't in the interface, though it
	// is exported, we can't pass the sink between functions.
	sink, err := send.NewInternalLogger(s.grip.ThresholdLevel(), s.grip.DefaultLevel())
	s.NoError(err)
	s.grip.SetSender(sink)

	msg := message.NewLinesMessage("foo")
	msgTwo := message.NewLinesMessage("bar")

	// when the conditional argument is true, it should work
	s.grip.conditionalSend(level.Emergency, true, msg)
	s.Equal(sink.GetMessage().Message, msg)

	// when the conditional argument is true, it should work, and the channel is fifo
	s.grip.conditionalSend(level.Emergency, false, msgTwo)
	s.grip.conditionalSend(level.Emergency, true, msg)
	s.Equal(sink.GetMessage().Message, msg)

	// change the order
	s.grip.conditionalSend(level.Emergency, true, msg)
	s.grip.conditionalSend(level.Emergency, false, msgTwo)
	s.Equal(sink.GetMessage().Message, msg)
}
开发者ID:tychoish,项目名称:grip,代码行数:25,代码来源:send_test.go

示例2: TestConditionalSendFatalDoesNotExitIfNotLoggable

func (s *GripInternalSuite) TestConditionalSendFatalDoesNotExitIfNotLoggable() {
	msg := message.NewLinesMessage("foo")
	s.grip.conditionalSendFatal(s.grip.DefaultLevel(), false, msg)

	s.True(level.Debug > s.grip.DefaultLevel())
	s.grip.conditionalSendFatal(level.Debug, true, msg)
}
开发者ID:tychoish,项目名称:grip,代码行数:7,代码来源:send_test.go

示例3: TestPanicSenderRespectsTThreshold

func (s *GripInternalSuite) TestPanicSenderRespectsTThreshold() {
	s.True(level.Debug > s.grip.DefaultLevel())

	// test that there is a no panic if the message isn't "logabble"
	defer func() {
		s.Nil(recover())
	}()

	s.grip.sendPanic(level.Debug, message.NewLinesMessage("foo"))
}
开发者ID:tychoish,项目名称:grip,代码行数:10,代码来源:send_test.go

示例4: TestPanicSenderActuallyPanics

func (s *GripInternalSuite) TestPanicSenderActuallyPanics() {
	// both of these are in anonymous functions so that the defers
	// cover the correct area.

	func() {
		// first make sure that the defualt send method doesn't panic
		defer func() {
			s.Nil(recover())
		}()

		s.grip.Sender().Send(s.grip.DefaultLevel(), message.NewLinesMessage("foo"))
	}()

	func() {
		// call a panic function with a recoverer set.
		defer func() {
			s.NotNil(recover())
		}()

		s.grip.sendPanic(s.grip.DefaultLevel(), message.NewLinesMessage("foo"))
	}()
}
开发者ID:tychoish,项目名称:grip,代码行数:22,代码来源:send_test.go

示例5: TestConditionalSendFatalExits

func TestConditionalSendFatalExits(t *testing.T) {
	std.UseNativeLogger()
	if os.Getenv("SHOULD_CRASH") == "1" {
		std.EmergencyFatalWhen(true, message.NewLinesMessage("foo"))
		return
	}

	cmd := exec.Command(os.Args[0], "-test.run=TestConditionalSendFatalExits")
	cmd.Env = append(os.Environ(), "SHOULD_CRASH=1")
	err := cmd.Run()
	if err == nil {
		t.Errorf("sendFatal should have exited 1, instead: %s", err.Error())
	}
}
开发者ID:tychoish,项目名称:grip,代码行数:14,代码来源:when_test.go

示例6: TestSendFatalExits

// This testing method uses the technique outlined in:
// http://stackoverflow.com/a/33404435 to test a function that exits
// since it's impossible to "catch" an os.Exit
func TestSendFatalExits(t *testing.T) {
	grip := NewGrip("test")
	if os.Getenv("SHOULD_CRASH") == "1" {
		grip.sendFatal(grip.DefaultLevel(), message.NewLinesMessage("foo"))
		return
	}

	cmd := exec.Command(os.Args[0], "-test.run=TestSendFatalExits")
	cmd.Env = append(os.Environ(), "SHOULD_CRASH=1")
	err := cmd.Run()
	if err == nil {
		t.Errorf("sendFatal should have exited 0, instead: %s", err.Error())
	}
}
开发者ID:tychoish,项目名称:grip,代码行数:17,代码来源:send_test.go

示例7: TestConditionalSendPanic

func (s *GripInternalSuite) TestConditionalSendPanic() {
	sink, err := send.NewInternalLogger(s.grip.ThresholdLevel(), s.grip.DefaultLevel())
	s.NoError(err)
	s.grip.SetSender(sink)

	msg := message.NewLinesMessage("foo")

	// first if the conditional is false, it can't panic.
	s.NotPanics(func() {
		s.grip.conditionalSendPanic(level.Emergency, false, msg)
	})

	// next, if the conditional is true it should panic
	s.Panics(func() {
		s.grip.conditionalSendPanic(level.Emergency, true, msg)
	})
}
开发者ID:tychoish,项目名称:grip,代码行数:17,代码来源:send_test.go

示例8: ErrorPanicln

func (g *Grip) ErrorPanicln(a ...interface{}) {
	g.sendPanic(level.Error, message.NewLinesMessage(a...))
}
开发者ID:tychoish,项目名称:grip,代码行数:3,代码来源:general.go

示例9: Warningln

func (g *Grip) Warningln(a ...interface{}) {
	g.sender.Send(level.Warning, message.NewLinesMessage(a...))
}
开发者ID:tychoish,项目名称:grip,代码行数:3,代码来源:general.go

示例10: Noticeln

func (g *Grip) Noticeln(a ...interface{}) {
	g.sender.Send(level.Notice, message.NewLinesMessage(a...))
}
开发者ID:tychoish,项目名称:grip,代码行数:3,代码来源:general.go

示例11: ErrorFatalln

func (g *Grip) ErrorFatalln(a ...interface{}) {
	g.sendFatal(level.Error, message.NewLinesMessage(a...))
}
开发者ID:tychoish,项目名称:grip,代码行数:3,代码来源:general.go

示例12: EmergencyFatalWhenln

func (g *Grip) EmergencyFatalWhenln(conditional bool, msg ...interface{}) {
	g.conditionalSendFatal(level.Emergency, conditional, message.NewLinesMessage(msg...))
}
开发者ID:tychoish,项目名称:grip,代码行数:3,代码来源:when.go

示例13: Debugln

func (g *Grip) Debugln(a ...interface{}) {
	g.sender.Send(level.Debug, message.NewLinesMessage(a...))
}
开发者ID:tychoish,项目名称:grip,代码行数:3,代码来源:general.go

示例14: ErrorPanicWhenln

func (g *Grip) ErrorPanicWhenln(conditional bool, msg ...interface{}) {
	g.conditionalSendPanic(level.Error, conditional, message.NewLinesMessage(msg...))
}
开发者ID:tychoish,项目名称:grip,代码行数:3,代码来源:when.go

示例15: CriticalWhenln

func (g *Grip) CriticalWhenln(conditional bool, msg ...interface{}) {
	g.CriticalWhen(conditional, message.NewLinesMessage(msg...))
}
开发者ID:tychoish,项目名称:grip,代码行数:3,代码来源:when.go


注:本文中的github.com/tychoish/grip/message.NewLinesMessage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。