Sha256: fa3bb7b8a906aaca84166d86504fefc1d9827bacf18a30736372d38367ac0c00

Contents?: true

Size: 1.06 KB

Versions: 27

Compression:

Stored size: 1.06 KB

Contents

module Calabash
  module Cucumber
    require "fileutils"
    require "run_loop"
    require "calabash-cucumber/dot_dir"

    # !@visibility private
    def self.log_to_file(message)
      timestamp = self.timestamp

      begin
        File.open(self.calabash_log_file, "a:UTF-8") do |file|
          message.split($-0).each do |line|
            file.write("#{timestamp} #{line}#{$-0}")
          end
        end
      rescue => e
        message =
          %Q{Could not write:

#{message}

to calabash.log because:

#{e}
}
        RunLoop.log_debug(message)
      end
    end

    private

    # @!visibility private
    def self.timestamp
      Time.now.strftime("%Y-%m-%d_%H-%M-%S")
    end

    # @!visibility private
    def self.logs_directory
      path = File.join(Calabash::Cucumber::DotDir.directory, "logs")
      FileUtils.mkdir_p(path)
      path
    end

    # @!visibility private
    def self.calabash_log_file
      path = File.join(self.logs_directory, "calabash.log")
      if !File.exist?(path)
        FileUtils.touch(path)
      end
      path
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
calabash-cucumber-0.23.7 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.23.6 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.23.5 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.23.4 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.23.3 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.23.2 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.23.1 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.23.0 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.22.2 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.21.10 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.21.8 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.21.7 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.21.6 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.21.5 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.21.4 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.21.2 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.21.1 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.20.5 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.20.4 lib/calabash-cucumber/logging.rb
calabash-cucumber-0.20.3 lib/calabash-cucumber/logging.rb