Skip to content

Commit

Permalink
Merge pull request #26 from zsolt-rozsnyai/patch-1
Browse files Browse the repository at this point in the history
Add documentation on how to skip default $stdout
  • Loading branch information
solnic authored Feb 5, 2024
2 parents 3ee2b99 + 3be3932 commit 34039a1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docsite/source/index.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ logger.info "Hello World"
# [test] [INFO] [2022-11-17 11:46:12 +0100] Hello World
```

### Skipping default behaviour

If you don't want to log to the default `$stdout` you can skip it by passing in a block to the
constructor:

```ruby
logger = Dry.Logger(:test) do |dispatcher|
dispatcher.add_backend(stream: "logs/test.log", template: :details)
end

# This goes to logs/test.log
logger.info "Hello World"
# [test] [INFO] [2022-11-17 11:46:12 +0100] Hello World
```

### Conditional logging

You can tell your backends when exactly they should be logging using `log_if` option. It can be set
Expand Down

0 comments on commit 34039a1

Please sign in to comment.