Skip to content

Commit 4c97c23

Browse files
c42ftkf
andauthored
Start some real documentation (#15)
Add a small intro/installation section; document progress logging and the exported API. Co-authored-by: Takafumi Arakaki <[email protected]>
1 parent 1769e86 commit 4c97c23

File tree

3 files changed

+64
-7
lines changed

3 files changed

+64
-7
lines changed

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,9 @@
55
[![Build Status](https://github.com/c42f/TerminalLoggers.jl/workflows/CI/badge.svg)](https://github.com/c42f/TerminalLoggers.jl/actions?query=workflow%3ACI)
66
[![Codecov](https://codecov.io/gh/c42f/TerminalLoggers.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/c42f/TerminalLoggers.jl)
77

8-
`TerminalLoggers` contains user interface utilities for displaying log messages
9-
in text terminals.
8+
TerminalLoggers provides a logger type `TerminalLogger` which can format your
9+
log messages in a richer way than the default `ConsoleLogger` which comes with
10+
the julia standard `Logging` library.
11+
12+
Read the [documentation](https://c42f.github.io/TerminalLoggers.jl/stable) for
13+
more information.

docs/src/index.md

+55-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,60 @@
11
# TerminalLoggers.jl
22

3-
```@index
3+
TerminalLoggers provides a logger type [`TerminalLogger`](@ref) which can
4+
format your log messages in a richer way than the default `ConsoleLogger` which
5+
comes with the julia standard `Logging` library.
6+
7+
8+
## Installation and setup
9+
10+
```julia-repl
11+
pkg> add https://github.com/c42f/TerminalLoggers.jl
12+
```
13+
14+
To use `TerminalLogger` in all your REPL sessions by default, you may add a
15+
snippet such as the following to your startup file (in `.julia/config/startup.jl`)
16+
17+
```julia
18+
atreplinit() do repl
19+
try
20+
@eval begin
21+
using Logging: global_logger
22+
using TerminalLoggers: TerminalLogger
23+
global_logger(TerminalLogger())
24+
end
25+
catch
26+
end
27+
end
28+
```
29+
30+
31+
## Progress bars
32+
33+
`TerminalLogger` displays progress logging as a set of progress bars which are
34+
cleanly separated from the rest of the program output at the bottom of the
35+
terminal. Try an example like the following
36+
37+
```julia
38+
global_logger(TerminalLogger(right_justify=120))
39+
for i=1:100
40+
if i == 50
41+
@warn "Middle of computation" i
42+
end
43+
sleep(0.01)
44+
@info "Some progress" progress=i/100
45+
end
46+
@info "Done"
447
```
548

6-
```@autodocs
7-
Modules = [TerminalLoggers]
49+
!!! note
50+
Rendering progress bars separately doesn't yet work on windows due to
51+
limitations of the windows console and its interaction with libuv.
52+
We expect this will eventually be solved with some combination of libuv
53+
updates and the new windows terminal.
54+
55+
56+
## API Reference
57+
58+
```@docs
59+
TerminalLogger
860
```

src/TerminalLogger.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
TerminalLogger(stream=stderr, min_level=$ProgressLevel; meta_formatter=default_metafmt,
33
show_limited=true, right_justify=0)
44
5-
Logger with formatting optimized for readability in a text console, for example
6-
interactive work with the Julia REPL.
5+
Logger with formatting optimized for interactive readability in a text console
6+
(for example, the Julia REPL). This is an enhanced version of the terminal
7+
logger `Logging.ConsoleLogger` which comes installed with Julia by default.
78
89
Log levels less than `min_level` are filtered out.
910

0 commit comments

Comments
 (0)