lib/simple_rotate/private.rb in simple_rotate-1.1.0 vs lib/simple_rotate/private.rb in simple_rotate-1.1.1

- old
+ new

@@ -43,15 +43,15 @@ @logf = File.open(@file_name, File::RDWR|File::CREAT|File::TRUNC) gtime = Time.new.to_i @logf.puts("created@#{gtime}@Please don't delete this line") @logf.close - rescue - SimpleRotate::Error.open(@file_name) - end + rescue + SimpleRotate::Error.open(@file_name) + end - openadd + openadd end # if file or directory exist, call error private def exist_error(file) @@ -80,11 +80,11 @@ que << [%{@compress}, %{false}] que << [%{@is_psync}, %{false}] que << [%{@sleep_time}, %{0}] que.each do |q| - if eval(%{#{q[0]} == nil}) + if !eval(%{self.instance_variable_defined? :#{q[0]}}) eval(%{#{q[0]} = #{q[1]}}) end end end @@ -211,10 +211,15 @@ # # @param string $log # @return string private def get_trimmed_log(log) - log = log.to_s + if log == nil + log = log.inspect + else + log = log.to_s + end + date = Time.now.strftime(@date_format) level = eval("LOG_LEVEL_#{@log_level}") return @logging_format.gsub("$DATE", date) .gsub("$LEVEL", level) .gsub("$LOG", log)