Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/ProgressLogging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ end
# previous `progress` key based specification, we create a custom
# string type that has `Progress` attached to it. This is used as the
# third argument `message` of `Logging.handle_message`.
struct ProgressString <: AbstractString
struct ProgressString
progress::Progress
end

Expand All @@ -208,13 +208,14 @@ Base.string(str::ProgressString) = str.progress.name

Base.print(io::IO, str::ProgressString) = print(io, string(str))
Base.convert(::Type{ProgressString}, str::ProgressString) = str
Base.convert(::Type{T}, str::ProgressString) where {T<:AbstractString} =
convert(T, str.progress.name)

# Define `cmp` to make `==` etc. work
Base.cmp(a::AbstractString, b::ProgressString) = cmp(a, string(b))
Base.cmp(a::ProgressString, b::AbstractString) = cmp(string(a), b)
Base.cmp(a::ProgressString, b::ProgressString) = cmp(string(a), string(b))
# Define `isless` and `==` to make comparisons work
Base.isless(a::AbstractString, b::ProgressString) = isless(a, string(b))
Base.isless(a::ProgressString, b::AbstractString) = isless(string(a), b)
Base.isless(a::ProgressString, b::ProgressString) = isless(string(a), string(b))
Base.:(==)(a::AbstractString, b::ProgressString) = a == string(b)
Base.:(==)(a::ProgressString, b::AbstractString) = string(a) == b
Base.:(==)(a::ProgressString, b::ProgressString) = string(a) == string(b)

# Avoid using `show(::IO, ::AbstractString)` which expects
# `Base.print_quoted` to work.
Expand Down