Class: PackageChanger::Log

Inherits:
Object
  • Object
show all
Defined in:
lib/PackageChanger/log.rb

Constant Summary collapse

DEFAULT_FILE =
Pathname.new '/var/log/packagechanger.log'
DATE_FORMAT =

date and line format

'%Y-%m-%d %H:%M:%S'

Instance Method Summary collapse

Constructor Details

#initializeLog

Returns a new instance of Log.



9
10
11
# File 'lib/PackageChanger/log.rb', line 9

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

Instance Method Details

#putsandlog(message) ⇒ Object



17
18
19
20
# File 'lib/PackageChanger/log.rb', line 17

def putsandlog(message)
  puts message
  write message
end

#write(message) ⇒ Object



13
14
15
# File 'lib/PackageChanger/log.rb', line 13

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