Rubyã§ç°¡åã«ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ã«ããè²ä»ãâtimestampã¹ã¯ãªããæ¹è¯
ã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ã§è²ãã¤ããã®ã¯ç«¯æ«ã¢ããªã±ã¼ã·ã§ã³ã ã¨å®çªã ã
Rubyã§è²ã¤ãæåãåºãå ´åãããããã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ãæ¸ãå¿
è¦ã¯ãªããTerm::ANSIColorã¨ããã©ã¤ãã©ãªã使ãã°ããã
ã¤ã³ã¹ãã¼ã«ã¯ãgem install term-ansicolorãã§ã
require 'term/ansicolor' class String include Term::ANSIColor end
ã¨ããã³ã¼ããå ¥ãã¦ããã°ãæååã«è²åã¡ã½ãããªã©ãå®ç¾©ããã¦ã¦ããããããè¨è¿°ã§ãããããããªãµãã«ã
print "red bold".red.bold, "\n"
timestampã³ãã³ããè²ä»ãã«ãã¦ã¿ã
[update] <2010-03-30 ç«> ã·ã°ãã«ã§çµäºããã¨ãã«ã¯ãããã»ã¹ãªãã¸ã§ã¯ãã表示ãã¦ã¿ãã
任意のプログラムを実行するとき開始/終了時のタイムスタンプを出力する方法 - http://rubikitch.com/に移転しましたã§ç´¹ä»ããtimestampã³ãã³ãã«è²ãã¤ãã¦ã¿ããéå§æå»ã»çµäºæå»ã»çµéæéã»çµäºã¹ãã¼ã¿ã¹ã表示ããã
#!/usr/local/bin/ruby191 require 'term/ansicolor' class String include Term::ANSIColor end start_time = Time.now cmdline = ARGV.join ' ' $stderr.puts ("=" * 60).green $stderr.puts "#{Time.now} start: #{cmdline.red}" $stderr.puts `free` $stderr.puts "-" * 60 system *ARGV secs = Time.now - start_time $stderr.puts "+" * 60 $stderr.puts $?.inspect if $?.signaled? $stderr.puts "#{Time.now} end: #{cmdline.red}" $stderr.puts ("%.2f seconds" % secs).yellow $stderr.puts "exitstatus = #{$?.exitstatus}" $stderr.puts ("-" * 60).green
[2009/12/30]追è¨
ã«ã©ã¼åãããtimestampã³ãã³ãã«cronã®ãã°ãåãããã¨ãããªããã°ãè¦ããããªã£ãããã£ã±ãè²ã®å¹æã¯çµ¶å¤§ã ã