Skip to content

Commit

Permalink
docs: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tauqeernasir authored Oct 13, 2021
1 parent 96afdb3 commit 5b7b777
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,38 @@ You can turn on/off some features of the logger by calling following methods on
- WithFileInfo() or WithoutFileInfo()

All methods return reference to the `Logger`, so they can easily be chained. Like `Logger.WithColor().WithoutTimestamp().WithoutFileInfo()`

#### Logging to file

```go

package main

import (
"os"

"github.com/tauqeernasir/gcl/gcl"
)

var Logger *gcl.Logger

func init() {
// create a file
f, err := os.Create("log.txt")
if err != nil {
panic("couldn't create log.txt file")
}

// provide file to logger
Logger = gcl.NewLogger(f).WithoutColor()
}

func main() {
Logger.Info("I am an information message.")
Logger.Error("I am an error message.")
Logger.Success("I am a success message.")
Logger.Warn("I am a warning message.")
Logger.Fatal("I am a fatal message.")
}

```

0 comments on commit 5b7b777

Please sign in to comment.