Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
dmachard committed Nov 20, 2023
1 parent f39613a commit 017ac8a
Showing 1 changed file with 27 additions and 5 deletions.
32 changes: 27 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# go-logger

Basic logger library with the following features:
Basic logger library with the following features:

- timestamp
- level support (INFO, ERROR and FATAL)
- verbose mode
- log to channel

Info log messages are redirected to stdout, stderr otherwise.

Expand All @@ -22,16 +24,36 @@ import (
"github.com/dmachard/go-logger"
)

logger := logger.New(true)
logger.Info("just a basic message!")
lg := logger.New(true)
lg.Info("just a basic message!")
```

Output example:

```
```bash
INFO: 2021/07/04 14:18:22.270971 just a basic message
```

## Usage example with channel

Create logger with channel

```go
import (
"github.com/dmachard/go-logger"
)

logsChan := make(chan logger.LogEntry, 10)

lg := logger.New(false)
lg.SetOutputChannel((logsChan))

lg.Info("just a basic message!")

entry := <-logsChan
fmt.Println(entry.Level, entry.Message)
```

## Testing

```bash
Expand All @@ -57,4 +79,4 @@ cpu: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
BenchmarkLogInfo-4 4094160 278.4 ns/op
PASS
ok github.com/dmachard/go-logger 1.449s
```
```

0 comments on commit 017ac8a

Please sign in to comment.