Module: Ghaki::NetSSH::Logger
Constant Summary collapse
- NO_OUTPUT =
'** NO OUTPUT **'
Instance Attribute Summary collapse
-
#should_log_command ⇒ Object
Returns the value of attribute should_log_command.
-
#should_log_output ⇒ Object
Returns the value of attribute should_log_output.
Instance Method Summary collapse
- #log_all_off(&block) ⇒ Object
-
#log_all_on(&block) ⇒ Object
TURN ON/OFF ALL LOGGING.
- #log_command!(title, cmd) ⇒ Object
- #log_command_off(&block) ⇒ Object
-
#log_command_on(&block) ⇒ Object
TURN COMMAND LOGGIN ON/OFF.
-
#log_exec!(title, cmd, &block) ⇒ Object
DO THE ACTUAL LOGGING WORK.
- #log_output_off(&block) ⇒ Object
-
#log_output_on(&block) ⇒ Object
TURN OUTPUT LOGGIN ON/OFF.
- #setup_logger(opts) ⇒ Object
Instance Attribute Details
#should_log_command ⇒ Object
Returns the value of attribute should_log_command.
9 10 11 |
# File 'lib/ghaki/net_ssh/logger.rb', line 9 def should_log_command @should_log_command end |
#should_log_output ⇒ Object
Returns the value of attribute should_log_output.
9 10 11 |
# File 'lib/ghaki/net_ssh/logger.rb', line 9 def should_log_output @should_log_output end |
Instance Method Details
#log_all_off(&block) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ghaki/net_ssh/logger.rb', line 39 def log_all_off &block out = '' old_out,old_cmd = @should_log_output,@should_log_command @should_log_output = @should_log_command = false if not block.nil? begin out = block.call ensure @should_log_output,@should_log_command = old_out,old_cmd end end out end |
#log_all_on(&block) ⇒ Object
TURN ON/OFF ALL LOGGING
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ghaki/net_ssh/logger.rb', line 25 def log_all_on &block out = '' old_out,old_cmd = @should_log_output,@should_log_command @should_log_output = @should_log_command = true if not block.nil? begin out = block.call ensure @should_log_output,@should_log_command = old_out,old_cmd end end out end |
#log_command!(title, cmd) ⇒ Object
131 132 133 |
# File 'lib/ghaki/net_ssh/logger.rb', line 131 def log_command! title, cmd logger.puts "#{title} #{@account.hostname} : #{cmd}" if @should_log_command end |
#log_command_off(&block) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/ghaki/net_ssh/logger.rb', line 70 def log_command_off &block out = '' orig,@should_log_command = @should_log_command,false if not block.nil? begin out = block.call ensure @should_log_command = orig end end out end |
#log_command_on(&block) ⇒ Object
TURN COMMAND LOGGIN ON/OFF
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ghaki/net_ssh/logger.rb', line 57 def log_command_on &block out = '' orig,@should_log_command = @should_log_command,true if not block.nil? begin out = block.call ensure @should_log_command = orig end end out end |
#log_exec!(title, cmd, &block) ⇒ Object
DO THE ACTUAL LOGGING WORK
117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/ghaki/net_ssh/logger.rb', line 117 def log_exec! title, cmd, &block log_command! title, cmd out = block.call || '' return out unless @should_log_output if out == '' logger.puts( NO_OUTPUT ) else logger.liner logger.puts( out ) logger.liner end out end |
#log_output_off(&block) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/ghaki/net_ssh/logger.rb', line 100 def log_output_off &block out = '' orig,@should_log_output = @should_log_output,false if not block.nil? begin out = block.call ensure @should_log_output = orig end end out end |
#log_output_on(&block) ⇒ Object
TURN OUTPUT LOGGIN ON/OFF
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ghaki/net_ssh/logger.rb', line 87 def log_output_on &block out = '' orig,@should_log_output = @should_log_output,true if not block.nil? begin out = block.call ensure @should_log_output = orig end end out end |
#setup_logger(opts) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/ghaki/net_ssh/logger.rb', line 13 def setup_logger opts @logger = opts[:logger] @should_log_command = opts[:log_ssh_command] @should_log_command = true if @should_log_command.nil? @should_log_output = opts[:log_ssh_output] @should_log_output = true if @should_log_output.nil? end |