guo-yong-zhi / WordCloud.jl

word cloud generator in julia
GNU General Public License v3.0
109 stars 2 forks source link

[Question] How to suppress logging/progress printing? #17

Closed svilupp closed 1 year ago

svilupp commented 1 year ago

Thank you for the amazing package.

I was wondering if there is a way to suppress all the printed messages when producing a word cloud?

I have disabled logging but there still a lot of commands sent to stdin (eg, here), which show up anyway.

My ideal outcome would be that I get only the word cloud output and none of the following messages:

total words: 63. Unique words: 43. After filtration: 42. The top 42 words are kept. angles = -60:60 mask size: 300×400, content area: 346² (53²/word) set fontsize ∈ [8.0, 300] set density = 0.5 The word "insightful"(56.063448564744085) is too big. Set maxfontsize = 50.883237416299686. The word "collaborative"(45.12210419223353) is too big. Set maxfontsize = 39.79636673099108. ⋯scale=59.76143046671968, density=0.5652075000000001 ↑ ⋯scale=56.208504238858396, density=0.5291157500000001 ↑ ⋯scale=53.16956950394639, density=0.4920475 ↓ fontsize ∈ [11.078697398031899, 39.79636673099108] ▸1. scale = 53.83598778968367 31 epochs Total words: 14. Unique words: 10. After filtration: 9. The top 9 words are kept. angles = 0 mask size: 300×400, content area: 346² (115²/word) set fontsize ∈ [8.0, 300] set density = 0.5 ⋯scale=129.09944487358058, density=0.640553 ↑ ⋯scale=114.05959947564652, density=0.5048582500000001 ↑ fontsize ∈ [29.435917304955776, 115.67395628431842] center the word "hazy" gathering style: rt = 1, ellipse ▸1. scale = 113.48417855265 25 epochs

guo-yong-zhi commented 1 year ago

https://docs.julialang.org/en/v1/base/io-network/#Base.redirect_stdio

I think you can redirect the stderr and stdout to devnull. Such as

wc = redirect_stdio(stdout=devnull, stderr=devnull) do
    wordcloud("get only the word cloud output") |> generate!
end