JuliaLogging / ProgressLogging.jl

MIT License
50 stars 8 forks source link

Add withprogress and logprogress macros #6

Closed tkf closed 5 years ago

tkf commented 5 years ago

Quoting the docstring:

@withprogress [name=""] ex

Create a lexical environment in which @logprogress can be used to emit progress log events without manually specifying the log level and _id.

@withprogress begin
    for i = 1:10
        sleep(0.5)
        @logprogress "iterating" progress=i/10
    end
end

An example usecase: https://github.com/tkf/Transducers.jl/pull/64/commits/f94ebc05497812dbd9f4e8b19c524d5fa21468eb#diff-c7e0e286be94a49828209e9f88753e8b

This lets people use somewhat low-level logging-base API (@withprogress and @logprogress) without referring to the lowest-level specification (_id and LogLevel).