Skip to content

Commit

Permalink
Start some real documentation (#15)
Browse files Browse the repository at this point in the history
Add a small intro/installation section; document progress logging and the exported API.

Co-authored-by: Takafumi Arakaki <[email protected]>
  • Loading branch information
c42f and tkf authored Feb 3, 2020
1 parent 1769e86 commit 4c97c23
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 7 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@
[![Build Status](https://github.com/c42f/TerminalLoggers.jl/workflows/CI/badge.svg)](https://github.com/c42f/TerminalLoggers.jl/actions?query=workflow%3ACI)
[![Codecov](https://codecov.io/gh/c42f/TerminalLoggers.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/c42f/TerminalLoggers.jl)

`TerminalLoggers` contains user interface utilities for displaying log messages
in text terminals.
TerminalLoggers provides a logger type `TerminalLogger` which can format your
log messages in a richer way than the default `ConsoleLogger` which comes with
the julia standard `Logging` library.

Read the [documentation](https://c42f.github.io/TerminalLoggers.jl/stable) for
more information.
58 changes: 55 additions & 3 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,60 @@
# TerminalLoggers.jl

```@index
TerminalLoggers provides a logger type [`TerminalLogger`](@ref) which can
format your log messages in a richer way than the default `ConsoleLogger` which
comes with the julia standard `Logging` library.


## Installation and setup

```julia-repl
pkg> add https://github.com/c42f/TerminalLoggers.jl
```

To use `TerminalLogger` in all your REPL sessions by default, you may add a
snippet such as the following to your startup file (in `.julia/config/startup.jl`)

```julia
atreplinit() do repl
try
@eval begin
using Logging: global_logger
using TerminalLoggers: TerminalLogger
global_logger(TerminalLogger())
end
catch
end
end
```


## Progress bars

`TerminalLogger` displays progress logging as a set of progress bars which are
cleanly separated from the rest of the program output at the bottom of the
terminal. Try an example like the following

```julia
global_logger(TerminalLogger(right_justify=120))
for i=1:100
if i == 50
@warn "Middle of computation" i
end
sleep(0.01)
@info "Some progress" progress=i/100
end
@info "Done"
```

```@autodocs
Modules = [TerminalLoggers]
!!! note
Rendering progress bars separately doesn't yet work on windows due to
limitations of the windows console and its interaction with libuv.
We expect this will eventually be solved with some combination of libuv
updates and the new windows terminal.


## API Reference

```@docs
TerminalLogger
```
5 changes: 3 additions & 2 deletions src/TerminalLogger.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
TerminalLogger(stream=stderr, min_level=$ProgressLevel; meta_formatter=default_metafmt,
show_limited=true, right_justify=0)
Logger with formatting optimized for readability in a text console, for example
interactive work with the Julia REPL.
Logger with formatting optimized for interactive readability in a text console
(for example, the Julia REPL). This is an enhanced version of the terminal
logger `Logging.ConsoleLogger` which comes installed with Julia by default.
Log levels less than `min_level` are filtered out.
Expand Down

2 comments on commit 4c97c23

@c42f
Copy link
Member Author

@c42f c42f commented on 4c97c23 Feb 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/8908

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 4c97c23beaa90b3fdc4846337acfcc2fc8dad30c
git push origin v0.1.0

Please sign in to comment.