#
# DNS Balance
#
# ログ出力
#
# By: YOKOTA Hiroshi <yokota@netlab.is.tsukuba.ac.jp>

# $Id: log_writer.rb,v 1.3 2002/06/08 16:27:31 elca Exp $

# ログ出力用排他処理
$loglock = Mutex::new

def put_log(str)
  $loglock.synchronize do
    $logout.print(str)
  end
end

# ログ出力
def logger(addr, status, name, namespace, answers)
  out = sprintf("%d.%d.%d.%d:%s:%s:%s",
		addr[0], addr[1], addr[2], addr[3],
		status,
		name,
		namespace)

  if answers == nil || answers == []
    out += ":\n"
  else
    s = []
    for i in answers
      s.push(sprintf("%d.%d.%d.%d", i[0], i[1], i[2], i[3]))
    end
    out += sprintf(":%s\n", s.join(" "))
  end
  put_log(out)
end

# end
