https://github.com/julialogging/logging2.jl
A logging library to stage new ideas for stdlib Logging
https://github.com/julialogging/logging2.jl
Last synced: 7 months ago
JSON representation
A logging library to stage new ideas for stdlib Logging
- Host: GitHub
- URL: https://github.com/julialogging/logging2.jl
- Owner: JuliaLogging
- License: mit
- Created: 2020-07-28T07:53:35.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-02-04T05:17:04.000Z (over 4 years ago)
- Last Synced: 2025-02-21T09:06:11.307Z (over 1 year ago)
- Language: Julia
- Size: 31.3 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Logging2
[](https://github.com/JuliaLogging/Logging2.jl/actions)
**Logging2** is a library which extends the standard Julia
[Logging library](https://docs.julialang.org/en/v1/stdlib/Logging) with
additional functionality. The intent of this library is to consolidate some
of the more useful "core" logging functionality from the wider Julia ecosystem,
and serve as a staging area to improve the logging standard library itself.
## How-To
### Redirect stdout or stderr to the logging system
Use `redirect_stdout` or `redirect_stderr` to redirect all strings written to
`stdout` or `stderr` to any `AbstractLogger` during the execution of a given
`do` block:
```julia
logger = current_logger() # or construct one explicitly
redirect_stdout(logger) do
println("Hi")
run(`ls`)
end
```
Note that `stdout` and `stderr` are **global** streams, so this logging choice
is made globally for the whole program. Therefore, you should probably only do
this at the top level of your application (certainly never in any library
code which you expect to run concurrently).