RubyのLoggerを用いて、Progress barを表示する
RubyでProgress barの実装が少なかったので + loggerで表示できたら素敵かなと思い、書きました。
Progress.rb
# log設定
logger = Logger.new(STDOUT)
logger.formatter = proc{|severity, datetime, progname, message|
message.nil? ? "\n" : "\rPROGRESS [#{datetime}] -- : [#{"%-20s" % ('=' * (message.to_f/5))}]#{"%3.1f" % message}%"
}
# log実行
1000.times do |num|
logger.info(100.0/num)
sleep 0.5
end
logger.info() # 改行で後処理
Author And Source
この問題について(RubyのLoggerを用いて、Progress barを表示する), 我々は、より多くの情報をここで見つけました https://qiita.com/monoquro/items/b8bfd1273e9fddbd4517著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .