Skip to content

Commit

Permalink
make the log levels customizable
Browse files Browse the repository at this point in the history
  • Loading branch information
samber committed Oct 25, 2023
1 parent 44caf28 commit f2fde65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ Attributes will be injected in log payload.

Attributes added to records are not accepted.

Other global parameters:

```go
slogloki.LogLevels = map[slog.Level]promtail.LogLevel{...}
```

### Example

```go
Expand Down
2 changes: 1 addition & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func (o Option) NewLokiHandler() slog.Handler {
}

clients := map[slog.Level]promtail.Client{}
for k, v := range logLevelConverter {
for k, v := range LogLevels {
conf := promtail.ClientConfig{
PushURL: o.Endpoint,
BatchWait: o.BatchWait,
Expand Down
2 changes: 1 addition & 1 deletion loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/afiskon/promtail-client/promtail"
)

var logLevelConverter = map[slog.Level]promtail.LogLevel{
var LogLevels = map[slog.Level]promtail.LogLevel{
slog.LevelDebug: promtail.DEBUG,
slog.LevelInfo: promtail.INFO,
slog.LevelWarn: promtail.WARN,
Expand Down

0 comments on commit f2fde65

Please sign in to comment.