Class: Log::Logger

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

Constant Summary collapse

LOG_DIR =
File.join(ENV['HOME'], '.hubeye', 'log')

Class Method Summary collapse

Class Method Details

.log(msg) ⇒ Object



5
6
7
8
9
# File 'lib/log/logger.rb', line 5

def self.log(msg)
  File.open(LOG_DIR, "a") do |f|
    f.puts(msg)
  end
end

.log_change(repo_name, commit_msg, committer, options = {}) ⇒ Object

If true, log to the terminal too (make sure that the process is not daemonized). Always log to the logfile.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/log/logger.rb', line 21

def self.log_change(repo_name, commit_msg, committer, options={})
  opts = {:include_terminal => false}.merge options
  change_msg = <<-MSG
  ===============================
  Repository: #{repo_name.downcase.strip} has changed (#{Time.now.strftime("%m/%d/%Y at %I:%M%p")})
  Commit msg: #{commit_msg}
  Committer : #{committer}
  ===============================
  MSG
  if opts[:include_terminal]
    STDOUT.puts change_msg
  end
  log(change_msg)
end

.relog(msg) ⇒ Object



11
12
13
14
15
16
# File 'lib/log/logger.rb', line 11

def self.relog(msg)
  #wipe the file and start anew
  File.open(LOG_DIR, "w") do |f|
    f.puts(msg)
  end
end