From 3fd30fef69ca28e5762d27331b1fd36e7e70bf4b Mon Sep 17 00:00:00 2001 From: Kyle Date: Tue, 22 Sep 2015 03:43:33 -0700 Subject: [PATCH] Tidying up. --- logging/example_test.go | 13 +++++++++++++ logging/log.go | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/logging/example_test.go b/logging/example_test.go index cf82ab4..a013ed1 100644 --- a/logging/example_test.go +++ b/logging/example_test.go @@ -29,3 +29,16 @@ func Example() { log.Notice("fare thee well") olog.Print("all good journeys must come to an end") } + +func ExampleNewFromFile() { + log, err := logging.NewFromFile("file logger", logging.LevelNotice, + "example.log", "example.err", true) + if err != nil { + log.Fatalf("failed to open logger: %v", err) + } + + log.Notice("hello, world") + log.Notice("some more things happening") + log.Warning("something suspicious has happened") + log.Alert("pick up that can, Citizen!") +} diff --git a/logging/log.go b/logging/log.go index 1337eaf..333579f 100644 --- a/logging/log.go +++ b/logging/log.go @@ -99,7 +99,7 @@ func New(domain string, level Level) *Logger { // NewWriters returns a new logger that writes to the w io.WriteCloser for // Notice and below and to the e io.WriteCloser for levels above Notice. If e is nil, w will be used. -func NewWriters(domain string, level Level, w, e io.WriteCloser) *Logger { +func NewFromWriters(domain string, level Level, w, e io.WriteCloser) *Logger { if e == nil { e = w } @@ -118,7 +118,7 @@ func NewWriters(domain string, level Level, w, e io.WriteCloser) *Logger { // NewFile returns a new logger that opens the files for writing. If // multiplex is true, output will be multiplexed to standard output // and standard error as well. -func NewFile(domain string, level Level, outFile, errFile string, multiplex bool) (*Logger, error) { +func NewFromFile(domain string, level Level, outFile, errFile string, multiplex bool) (*Logger, error) { l := &Logger{ domain: domain, level: level,