Class: Hubeye::Log::Logger

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

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.log(msg) ⇒ Object



7
8
9
10
11
# File 'lib/hubeye/log/logger.rb', line 7

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 :include_terminal => true, log to the terminal too (make sure that the process is not daemonized). Always log to the logfile.



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

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



13
14
15
16
17
18
# File 'lib/hubeye/log/logger.rb', line 13

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