Skip to content

Commit 1580ce2

Browse files
authored
Merge pull request #5 for v0.3.1 Release
2 parents ceb7a2f + e89ae1a commit 1580ce2

File tree

7 files changed

+30
-13
lines changed

7 files changed

+30
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# log - aah framework
22
[![Build Status](https://travis-ci.org/go-aah/log.svg?branch=master)](https://travis-ci.org/go-aah/log) [![codecov](https://codecov.io/gh/go-aah/log/branch/master/graph/badge.svg)](https://codecov.io/gh/go-aah/log/branch/master) [![Go Report Card](https://goreportcard.com/badge/aahframework.org/log.v0)](https://goreportcard.com/report/aahframework.org/log.v0)
3-
[![Version](https://img.shields.io/badge/version-0.3-blue.svg)](https://github.com/go-aah/log/releases/latest) [![GoDoc](https://godoc.org/aahframework.org/log.v0?status.svg)](https://godoc.org/aahframework.org/log.v0)
3+
[![Version](https://img.shields.io/badge/version-0.3.1-blue.svg)](https://github.com/go-aah/log/releases/latest) [![GoDoc](https://godoc.org/aahframework.org/log.v0?status.svg)](https://godoc.org/aahframework.org/log.v0)
44
[![License](https://img.shields.io/github/license/go-aah/log.svg)](LICENSE)
55

6-
***v0.3 [released](https://github.com/go-aah/log/releases/latest) and tagged on May 16, 2017***
6+
***v0.3.1 [released](https://github.com/go-aah/log/releases/latest) and tagged on May 16, 2017***
77

88
Simple, flexible & powerful `Go` logger inspired by standard logger & Google glog. aah framework utilizes `log` library across.
99

console_receiver_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package log
66

77
import (
88
"testing"
9-
"time"
109

1110
"aahframework.org/config.v0"
1211
"aahframework.org/test.v0/assert"
@@ -122,5 +121,5 @@ func testConsoleLogger(t *testing.T, cfgStr string) {
122121
logger.Error("Yes, yes, yes - finally an error")
123122
logger.Errorf("Yes, yes, yes - %v", "finally an error")
124123

125-
time.Sleep(1 * time.Millisecond)
124+
waitToDrain(logger)
126125
}

default.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ func SetPattern(pattern string) error {
138138
return std.SetPattern(pattern)
139139
}
140140

141+
// IsBufferEmpty returns true if logger buffer is empty otherwise false.
142+
// This method can be used to ensure all the log entry is written successfully.
143+
func IsBufferEmpty() bool {
144+
return std.IsBufferEmpty()
145+
}
146+
141147
func init() {
142148
cfg, _ := config.ParseString("log { }")
143149
std, _ = New(cfg)

default_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package log
66

77
import (
88
"testing"
9-
"time"
109

1110
"aahframework.org/config.v0"
1211
"aahframework.org/test.v0/assert"
@@ -43,7 +42,7 @@ func TestDefaultLogger(t *testing.T) {
4342
testStdPanic("panicf", "this is panicf")
4443
testStdPanic("panicln", "this is panicln")
4544

46-
time.Sleep(1 * time.Millisecond)
45+
waitToDrain(std)
4746
}
4847

4948
func TestDefaultLoggerMisc(t *testing.T) {
@@ -56,7 +55,7 @@ func TestDefaultLoggerMisc(t *testing.T) {
5655

5756
assert.Nil(t, SetLevel("trace"))
5857
assert.Nil(t, SetPattern("%level:-5 %message"))
59-
time.Sleep(1 * time.Millisecond)
58+
waitToDrain(std)
6059
}
6160

6261
func testStdPanic(method, msg string) {

file_receiver_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ package log
66

77
import (
88
"testing"
9-
"time"
109

1110
"aahframework.org/config.v0"
1211
"aahframework.org/test.v0/assert"
1312
)
1413

15-
func TestFileLoggerDailyRotation(t *testing.T) {
14+
func TestFileLoggerRotation(t *testing.T) {
1615
cleaupFiles("*.log")
1716
fileConfigStr1 := `
1817
log {
@@ -161,5 +160,5 @@ func testFileLogger(t *testing.T, cfgStr string, loop int) {
161160
logger.Errorf("Yes, yes, yes - %v", "finally an error")
162161
}
163162

164-
time.Sleep(2 * time.Millisecond)
163+
waitToDrain(logger)
165164
}

log.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const (
6565

6666
var (
6767
// Version no. of aahframework.org/log library
68-
Version = "0.3"
68+
Version = "0.3.1"
6969

7070
// FmtFlags is the list of log format flags supported by aah/log library
7171
// Usage of flag order is up to format composition.
@@ -205,8 +205,14 @@ func (l *Logger) SetReceiver(receiver Receiver) error {
205205
return l.receiver.Init(l.cfg)
206206
}
207207

208+
// IsBufferEmpty returns true if logger buffer is empty otherwise false.
209+
// This method can be used to ensure all the log entry is written successfully.
210+
func (l *Logger) IsBufferEmpty() bool {
211+
return len(l.ec) == 0
212+
}
213+
208214
//‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
209-
// Logger methods
215+
// Logger logging methods
210216
//_______________________________________
211217

212218
// Error logs message as `ERROR`. Arguments handled in the mananer of `fmt.Print`.

log_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestLogDefault(t *testing.T) {
3333
testPanic(logger, "panic", "this is panic")
3434
testPanic(logger, "panicf", "this is panicf")
3535
testPanic(logger, "panicln", "this is panicln")
36-
time.Sleep(1 * time.Millisecond)
36+
waitToDrain(logger)
3737
}
3838

3939
func TestMisc(t *testing.T) {
@@ -120,3 +120,11 @@ func cleaupFiles(match string) {
120120
}
121121
}
122122
}
123+
124+
func waitToDrain(l *Logger) {
125+
for {
126+
if l.IsBufferEmpty() {
127+
break
128+
}
129+
}
130+
}

0 commit comments

Comments
 (0)