Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging() in .juliarc.jl does not work #24028

Open
chakravala opened this issue Oct 6, 2017 · 3 comments
Open

logging() in .juliarc.jl does not work #24028

chakravala opened this issue Oct 6, 2017 · 3 comments

Comments

@chakravala
Copy link
Contributor

This is an issue related to #16213

The logging function does not have any effect when used from .juliarc.jl

For example, in my case I needed to overwrite the Base.show_delim_array method so I used

logging(DevNull,Base,:show_delim_array;kind=:warn)

as explained on discourse

Using this in the REPL after julia has loaded is no problem, but it does not work from .juliarc.jl and the warnings are still displayed anyway.

@c42f
Copy link
Member

c42f commented Dec 15, 2017

logging() is now deprecated by #24490 so this issue is somewhat obsolete.

In theory the new infrastructure allows you to do what you want, but it's immature and there's still various things to fix. Can you show the exact code which triggers the warning which you're trying to silence?

@c42f c42f mentioned this issue Dec 15, 2017
6 tasks
@chakravala
Copy link
Contributor Author

chakravala commented Dec 16, 2017

Here is the code I wanted to silence:

logging(DevNull,Base,:show_delim_array;kind=:warn)
logging(DevNull,Main,:show_delim_array;kind=:warn)
import Base.show_delim_array
function show_delim_array(io::IO, itr::Union{AbstractArray,SimpleVector}, op, delim, cl,
                          delim_one, i1=first(linearindices(itr)), l=last(linearindices(itr)))
    print(io, op)
    if !Base.show_circular(io, itr)
        recur_io = IOContext(io, :SHOWN_SET => itr)
        if !haskey(io, :compact)
            recur_io = IOContext(recur_io, :compact => true)
        end
        first = true
        i = i1
        if l >= i1
            while true
                if !isassigned(itr, i)
                    print(io, undef_ref_str)
                else
                    x = itr[i]
                    show(recur_io, x)
                end
                i += 1
                if i > l
                    delim_one && first && print(io, delim)
                    break
                end
                first = false
                print(io, delim)
            end
        end
    end
    print(io, cl)
end
function show_delim_array(io::IO, itr, op, delim, cl, delim_one, i1=1, n=typemax(Int))
    print(io, op)
    if !Base.show_circular(io, itr)
        recur_io = IOContext(io, :SHOWN_SET => itr)
        state = start(itr)
        first = true
        while i1 > 1 && !done(itr, state)
            _, state = next(itr, state)
            i1 -= 1
        end
        if !done(itr, state)
            while true
                x, state = next(itr, state)
                show(recur_io, x)
                i1 += 1
                if done(itr, state) || i1 > n
                    delim_one && first && print(io, delim)
                    break
                end
                first = false
                print(io, delim)
            end
        end
    end
    print(io, cl)
end

It's to make the display output of Array's back to the way it was before (without spaces).

@c42f
Copy link
Member

c42f commented Dec 17, 2017

Thanks - that confirms the associated warning "WARNING: Method definition ... overwritten at ..." is coming from the runtime in gf.c. So this issue isn't sorted out in 0.7 quite yet, but should be as part of the second point listed at #25109

@c42f c42f mentioned this issue Dec 17, 2017
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants