Class: Pike::Logger

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

Class Method Summary collapse

Class Method Details

.closeObject

Closes the log file



65
66
67
# File 'lib/pike/logger.rb', line 65

def close
  @log.close if @log
end

.initObject

Call this if Main.get(:log_file) is finally determined



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/pike/logger.rb', line 9

def init
  setup_logfile

  log(@log_buffer.string) if @log_buffer

  log
  log("Timestamp: #{Time.now}")
  log
  log('Starting build ...')
  log
end

.log(what = ' ') ⇒ Object

Logs a String or (if no param is given) a line break. Can be called before Logger.init, then everything will be buffered and written to the log file after it is initialized



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pike/logger.rb', line 28

def log(what = ' ')
  if @log
    log_target = @log
  else
    @log_buffer = StringIO.new unless @log_buffer
    log_target =  @log_buffer
  end

  log_target.puts "#{what}\n"
  log_target.flush
end

.log_bannerObject

The banner or header for the log file containing some debug infos



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/pike/logger.rb', line 45

def log_banner
  log('#######################################')
  log('#                                     #')
  log('#   PIKE >> Intelligent Deployments   #')
  log('#                                     #')
  log('#######################################')
  log
  log("Pike version: #{Pike::VERSION.to_s}")
  log("Ruby version: #{RUBY_VERSION}p#{RUBY_PATCHLEVEL} on #{RUBY_PLATFORM}")
  log
  log('Documentation: https://github.com/phortx/pike/wiki')
  log('Issues: https://github.com/phortx/pike')
  log
end