Skip to content

Commit

Permalink
Add TUI to the README and some updates
Browse files Browse the repository at this point in the history
  • Loading branch information
fhunleth committed Oct 28, 2023
1 parent fdda3d7 commit f1cc38d
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,25 @@ Logger.configure_backend(RingLogger, max_size: 1024)
See the example project for a hands-on walk-through of using the logger. Read on
for the highlights.

Log messages aren't printed to the console by default. If you're seeing them,
they may be coming from Elixir's default `:console` logger.
For the purpose of the example, when you're in IEx, log messages shouldn't be
printed to the console by default. They'll be coming from the console logger, so
turn them off:

To see log messages as they come in, call `RingLogger.attach()` and then to make
the log messages stop, call `RingLogger.detach()`. The `attach` method takes
options if you want to limit the log level, change the formatting, etc.
```elixir
iex> Logger.remove_backend(:console)
:ok
```

To see log messages as they come in with RingLogger, call `RingLogger.attach()`
and then to make the log messages stop, call `RingLogger.detach()`. The `attach`
method takes options if you want to limit the log level, change the formatting,
etc.

Here's an example:

```elixir
iex> Logger.add_backend(RingLogger)
{:ok, #PID<0.199.0>}
iex> Logger.remove_backend(:console)
:ok
iex> RingLogger.attach
:ok
iex> require Logger
Expand All @@ -106,11 +111,8 @@ iex> Logger.info("hello")
14:04:52.516 [info] hello
```

This probably isn't too exciting until you see that it works on remote shells as
well (the `:console` logger doesn't do this).

Say you prefer polling for log messages rather than having them print over your
console at random times. If you're still attached, then `detach` and `next`:
If you prefer polling for log messages rather than having them print when they
show up. If you're still attached, then `detach` and `next`:

```elixir
iex> RingLogger.detach
Expand Down Expand Up @@ -152,6 +154,17 @@ iex> RingLogger.grep(~r/[Nn]eedle/)
16:55:41.614 [info] Needle in a haystack
```

## RingLogger TUI

RingLogger provides a simple text UI that lets you access log viewing features
in a friendly way.

```elixir
iex> RingLogger.viewer()
```

Type `h` and then enter for help.

## Module and Application Level Filtering

If you want to filter a module or modules at a particular level you pass a map
Expand Down

0 comments on commit f1cc38d

Please sign in to comment.