Skip to content

Commit

Permalink
Merge pull request #3 from timehop/better-default-flags
Browse files Browse the repository at this point in the history
Use the same default flags as stdlib’s log I just think this is what most Go developers will expect; I know I did.
  • Loading branch information
aviflax committed Apr 15, 2015
2 parents 267e234 + 7cc7fa2 commit f7b5bd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions log/logging.go
Expand Up @@ -57,7 +57,7 @@ const (
FlagsPrecisionTime = log.Lmicroseconds
FlagsLongFile = log.Llongfile
FlagsShortFile = log.Lshortfile
FlagsDefault = FlagsNone
FlagsDefault = log.LstdFlags
)

var (
Expand Down Expand Up @@ -88,7 +88,11 @@ func init() {
Level = LevelTrace
}

Flags, _ = strconv.Atoi(os.Getenv("LOG_FORMAT"))
var err error
Flags, err = strconv.Atoi(os.Getenv("LOG_FORMAT"))
if err != nil {
Flags = FlagsDefault
}

DefaultLogger = New()
}
Expand Down
1 change: 1 addition & 0 deletions log/logging_test.go
Expand Up @@ -16,6 +16,7 @@ var _ = Describe("Logging functions", func() {
BeforeEach(func() {
output = new(bytes.Buffer)
log.Level = log.LevelTrace
log.SetTimestampFlags(log.FlagsNone)
log.SetOutput(output)
})

Expand Down

0 comments on commit f7b5bd9

Please sign in to comment.