Skip to content

Commit

Permalink
Added New func to Builder
Browse files Browse the repository at this point in the history
  • Loading branch information
anuptalwalkar committed Nov 16, 2016
1 parent 158e6de commit 094fb14
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
5 changes: 5 additions & 0 deletions core/ulog/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ func Builder() *LogBuilder {
return &LogBuilder{}
}

// New instance of ulog.Log is returned with the default setup
func New() Log {
return Builder().Build()
}

// WithConfiguration sets up configuration for the log builder
func (lb *LogBuilder) WithConfiguration(logConfig Configuration) *LogBuilder {
lb.logConfig = logConfig
Expand Down
2 changes: 1 addition & 1 deletion core/ulog/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func withLogger(t *testing.T, f func(*LogBuilder, string, string)) {
func TestDefaultPackageLogger(t *testing.T) {
withLogger(t, func(builder *LogBuilder, tmpDir string, logFile string) {
defer testutils.EnvOverride(t, config.EnvironmentKey(), "development")()
log := Builder().Build()
log := New()
zaplogger := log.RawLogger()
assert.Equal(t, zap.DebugLevel, zaplogger.Level())

Expand Down
4 changes: 2 additions & 2 deletions core/ulog/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (m *marshalObject) MarshalLog(kv zap.KeyValue) error {
}

func TestFieldConversion(t *testing.T) {
log := Builder().Build()
log := New()
base := log.(*baselogger)

assert.Equal(t, zap.Bool("a", true), base.fieldsConversion("a", true)[0])
Expand All @@ -121,7 +121,7 @@ func TestFieldConversion(t *testing.T) {
}

func TestRawLogger(t *testing.T) {
log := Builder().Build()
log := New()
assert.NotNil(t, log.RawLogger())
}

Expand Down
4 changes: 2 additions & 2 deletions service/host_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func TestOnCriticalError_ObserverShutdown(t *testing.T) {
sh := &host{
observer: o,
serviceCore: serviceCore{
log: ulog.Builder().Build(),
log: ulog.New(),
},
}

Expand Down Expand Up @@ -258,7 +258,7 @@ func TestStartHost_WithErrors(t *testing.T) {
func makeHost() *host {
return &host{
serviceCore: serviceCore{
log: ulog.Builder().Build(),
log: ulog.New(),
},
}
}
2 changes: 1 addition & 1 deletion service/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAddModules_Errors(t *testing.T) {
}

func TestWithLogger_OK(t *testing.T) {
logger := ulog.Builder().Build()
logger := ulog.New()
assert.NotPanics(t, func() {
New(WithLogger(logger))
})
Expand Down

0 comments on commit 094fb14

Please sign in to comment.