Class: Overcommit::Logger

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

Overview

Encapsulates all communication to an output source.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out) ⇒ Logger

Returns a new instance of Logger.



9
10
11
# File 'lib/overcommit/logger.rb', line 9

def initialize(out)
  @out = out
end

Class Method Details

.silentObject

Helper for creating a logger which outputs nothing.



5
6
7
# File 'lib/overcommit/logger.rb', line 5

def self.silent
  new(File.open('/dev/null', 'w'))
end

Instance Method Details

#bold(str) ⇒ Object



21
22
23
# File 'lib/overcommit/logger.rb', line 21

def bold(str)
  color('1;37', str)
end

#bold_error(str) ⇒ Object



29
30
31
# File 'lib/overcommit/logger.rb', line 29

def bold_error(str)
  color('1;31', str)
end

#bold_warning(str) ⇒ Object



41
42
43
# File 'lib/overcommit/logger.rb', line 41

def bold_warning(str)
  color('1;33', str)
end

#error(str) ⇒ Object



25
26
27
# File 'lib/overcommit/logger.rb', line 25

def error(str)
  color(31, str)
end

#log(*args) ⇒ Object



17
18
19
# File 'lib/overcommit/logger.rb', line 17

def log(*args)
  @out.puts(*args)
end

#partial(*args) ⇒ Object



13
14
15
# File 'lib/overcommit/logger.rb', line 13

def partial(*args)
  @out.print(*args)
end

#success(str) ⇒ Object



33
34
35
# File 'lib/overcommit/logger.rb', line 33

def success(str)
  color(32, str)
end

#warning(str) ⇒ Object



37
38
39
# File 'lib/overcommit/logger.rb', line 37

def warning(str)
  color(33, str)
end