Class: Pwrake::LogExecutor

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Singleton
Defined in:
lib/pwrake/worker/log_executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeLogExecutor

Returns a new instance of LogExecutor.



28
29
30
31
32
# File 'lib/pwrake/worker/log_executor.rb', line 28

def initialize
  @level = ::Logger::DEBUG
  @logger = @logger_stderr = DummyLogger.new
  @logger.level = @level
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



34
35
36
# File 'lib/pwrake/worker/log_executor.rb', line 34

def path
  @path
end

Instance Method Details

#closeObject



60
61
62
63
64
65
66
67
68
69
# File 'lib/pwrake/worker/log_executor.rb', line 60

def close
  if @log_dir
    @dir.close_messages.each{|m| @logger.info(m)}
    @logger = @logger_stderr
    @opened = false
    @logger_file.close
    @logger_file = nil
    @dir.close
  end
end

#init(option) ⇒ Object



36
37
38
39
# File 'lib/pwrake/worker/log_executor.rb', line 36

def init(option)
  @option = option
  @log_dir = @option[:log_dir]
end

#joinObject



71
72
# File 'lib/pwrake/worker/log_executor.rb', line 71

def join
end

#kill(sig) ⇒ Object



74
75
# File 'lib/pwrake/worker/log_executor.rb', line 74

def kill(sig)
end

#open(dir_class) ⇒ Object



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

def open(dir_class)
  if @log_dir
    @dir = dir_class.new
    @dir.open
    @path = @dir.log_path
    fn = "worker-#{Socket.gethostname}-#{Process.pid}.log"
    @logfile = (@path + fn).to_s
    ::FileUtils.mkdir_p(@path.to_s)
    @logger = @logger_file = ::Logger.new(@logfile)
    @opened = true
    @logger.level = @level
    @dir.open_messages.each{|m| @logger.info(m)}
  end
end

#opened?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/pwrake/worker/log_executor.rb', line 41

def opened?
  @opened
end