Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
Add SetTemplate to console logger. Closes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
aphistic committed Oct 2, 2015
1 parent 331edbe commit 5389fca
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions console_logger.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gomol

import (
"errors"
"fmt"
"github.com/mgutz/ansi"
)
Expand Down Expand Up @@ -74,6 +75,15 @@ func (l *ConsoleLogger) SetBase(base *Base) {
l.base = base
}

func (l *ConsoleLogger) SetTemplate(tpl *Template) error {
if tpl == nil {
return errors.New("A template must be provided")
}
l.tpl = tpl

return nil
}

func (l *ConsoleLogger) InitLogger() error {
l.isInitialized = true
return nil
Expand Down
13 changes: 13 additions & 0 deletions console_logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ func (s *GomolSuite) TestIssue5StringFormatting(c *C) {

// General tests

func (s *GomolSuite) TestConsoleSetTemplate(c *C) {
cl, err := NewConsoleLogger(nil)
c.Check(cl.tpl, NotNil)

err = cl.SetTemplate(nil)
c.Check(err, NotNil)

tpl, err := NewTemplate("")
c.Assert(err, IsNil)
err = cl.SetTemplate(tpl)
c.Check(err, IsNil)
}

func (s *GomolSuite) TestConsoleInitLogger(c *C) {
cl, err := NewConsoleLogger(nil)
c.Assert(err, IsNil)
Expand Down

0 comments on commit 5389fca

Please sign in to comment.