Sha256: 1dab79910c4a0f4ab3f8bdfe52767e2e08cd6b3fca80584f525962a6ffd5f773

Contents?: true

Size: 591 Bytes

Versions: 2

Compression:

Stored size: 591 Bytes

Contents

# frozen_string_literal: true
module PackageChanger
  class Log
    DEFAULT_FILE = Pathname.new '/var/log/packagechanger.log'

    # date and line format
    DATE_FORMAT = '%Y-%m-%d %H:%M:%S'

    def initialize
      File.write(DEFAULT_FILE, "≈≈≈ PackageChanger ≈≈≈\n", mode: 'a') unless (DEFAULT_FILE.file? && DEFAULT_FILE.writable?)
    end

    def write(message)
      File.write(DEFAULT_FILE, "#{Time.now.strftime(DATE_FORMAT)} - #{message}\n", mode: 'a')
    end

    def putsandlog(message)
      puts message
      write message
    end
  end
  # Class Log
end
# MOdule

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
PackageChanger-0.3.1 lib/PackageChanger/log.rb
PackageChanger-0.3.0 lib/PackageChanger/log.rb