Exemple #1
0
func (s *GripSuite) TestSenderGetterReturnsExpectedJournaler() {
	grip := NewJournaler("sender_swap")
	s.Equal(grip.Name(), "sender_swap")
	s.Equal(grip.Sender().Name(), "bootstrap")

	err := grip.UseNativeLogger()
	s.NoError(err)

	s.Equal(grip.Name(), "sender_swap")
	s.NotEqual(grip.Sender().Name(), "bootstrap")
	ns, _ := send.NewNativeLogger("native_sender", s.grip.Sender().ThresholdLevel(), s.grip.Sender().DefaultLevel())
	defer ns.Close()
	s.IsType(grip.Sender(), ns)

	err = grip.UseFileLogger("foo")
	s.NoError(err)

	defer func() { std.CatchError(os.Remove("foo")) }()

	s.Equal(grip.Name(), "sender_swap")
	s.NotEqual(grip.Sender(), ns)
	fs, _ := send.NewFileLogger("file_sender", "foo", s.grip.Sender().ThresholdLevel(), s.grip.Sender().DefaultLevel())
	defer fs.Close()
	s.IsType(grip.Sender(), fs)
}
Exemple #2
0
// UseNativeLogger sets the Journaler to use a native, standard
// output, logging instance, without changing the configuration of the
// Journaler.
func (g *Grip) UseNativeLogger() error {
	// name, threshold, default
	sender, err := send.NewNativeLogger(g.name, g.sender.ThresholdLevel(), g.sender.DefaultLevel())
	g.SetSender(sender)
	return err
}
Exemple #3
0
func (s *GripInternalSuite) SetupTest() {
	s.grip.SetName(s.name)
	sender, err := send.NewNativeLogger(s.name, s.grip.ThresholdLevel(), s.grip.DefaultLevel())
	s.NoError(err)
	s.grip.SetSender(sender)
}