From f82af55d2f5643e76f6ccece932386a6881c269a Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 8 Mar 2020 21:01:27 -0700 Subject: [PATCH 1/2] New API: ProgressLogging.implemented_by(logger) --- src/ProgressLogging.jl | 18 ++++++++++++++++++ test/test_misc.jl | 11 +++++++++++ 2 files changed, 29 insertions(+) create mode 100644 test/test_misc.jl diff --git a/src/ProgressLogging.jl b/src/ProgressLogging.jl index 0695159..696ed88 100644 --- a/src/ProgressLogging.jl +++ b/src/ProgressLogging.jl @@ -151,6 +151,8 @@ function Logging.handle_message(logger::MyLogger, args...; kwargs...) # handle normal log record end ``` + +Progress monitors also should define [`implemented_by`](@ref). """ asprogress(_level, progress::Progress, _args...; _...) = progress function asprogress( @@ -506,4 +508,20 @@ function make_count_to_frac(iterators...) return count_to_frac end +""" + ProgressLogging.implemented_by(logger::AbstractLogger) :: Bool + +Check if ProgressLogging protocol is supported by `logger`. + +# Implementation + +A progress monitor `CustomLogger <: AbstractLogger` should define + +```julia +ProgressLogging.implemented_by(::CustomLogger) = true +``` +""" +implemented_by +implemented_by(@nospecialize(logger::Logging.AbstractLogger)) = false + end # module diff --git a/test/test_misc.jl b/test/test_misc.jl new file mode 100644 index 0000000..acf4857 --- /dev/null +++ b/test/test_misc.jl @@ -0,0 +1,11 @@ +module TestMisc + +using ProgressLogging +using Test +using Logging + +@testset "implemented_by" begin + @test ProgressLogging.implemented_by(NullLogger()) == false +end + +end # module From 5cb2d2e57f9d84606b927aa4c03e9e405d896c94 Mon Sep 17 00:00:00 2001 From: Takafumi Arakaki Date: Sun, 8 Mar 2020 21:53:38 -0700 Subject: [PATCH 2/2] s/implemented_by/implementedby/g to be compatible with asprogress --- src/ProgressLogging.jl | 10 +++++----- test/test_misc.jl | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ProgressLogging.jl b/src/ProgressLogging.jl index 696ed88..ce1a3ec 100644 --- a/src/ProgressLogging.jl +++ b/src/ProgressLogging.jl @@ -152,7 +152,7 @@ function Logging.handle_message(logger::MyLogger, args...; kwargs...) end ``` -Progress monitors also should define [`implemented_by`](@ref). +Progress monitors also should define [`implementedby`](@ref). """ asprogress(_level, progress::Progress, _args...; _...) = progress function asprogress( @@ -509,7 +509,7 @@ function make_count_to_frac(iterators...) end """ - ProgressLogging.implemented_by(logger::AbstractLogger) :: Bool + ProgressLogging.implementedby(logger::AbstractLogger) :: Bool Check if ProgressLogging protocol is supported by `logger`. @@ -518,10 +518,10 @@ Check if ProgressLogging protocol is supported by `logger`. A progress monitor `CustomLogger <: AbstractLogger` should define ```julia -ProgressLogging.implemented_by(::CustomLogger) = true +ProgressLogging.implementedby(::CustomLogger) = true ``` """ -implemented_by -implemented_by(@nospecialize(logger::Logging.AbstractLogger)) = false +implementedby +implementedby(@nospecialize(logger::Logging.AbstractLogger)) = false end # module diff --git a/test/test_misc.jl b/test/test_misc.jl index acf4857..7bcc812 100644 --- a/test/test_misc.jl +++ b/test/test_misc.jl @@ -4,8 +4,8 @@ using ProgressLogging using Test using Logging -@testset "implemented_by" begin - @test ProgressLogging.implemented_by(NullLogger()) == false +@testset "implementedby" begin + @test ProgressLogging.implementedby(NullLogger()) == false end end # module