Class: Capistrano::LogWithAwesome
- Inherits:
-
Logger
- Object
- Logger
- Capistrano::LogWithAwesome
- Defined in:
- lib/capistrano/log_with_awesome.rb,
lib/capistrano/log_with_awesome/version.rb
Constant Summary collapse
- VERSION =
'0.0.2'
Class Method Summary collapse
-
.init(config) ⇒ Object
replaces the built in Capistrano logger with awesome.
- .log_with_awesome(message) ⇒ Object
Instance Method Summary collapse
-
#log(level, message, line_prefix = nil) ⇒ Object
Log and do awesome things I wish there was a nicer way to do this.
Class Method Details
.init(config) ⇒ Object
replaces the built in Capistrano logger with awesome
6 7 8 9 10 11 |
# File 'lib/capistrano/log_with_awesome.rb', line 6 def self.init(config) @config = config level = @config.logger.level @config.logger = new @config.logger.level = level end |
.log_with_awesome(message) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/capistrano/log_with_awesome.rb', line 13 def self.log_with_awesome() @buffer ||= [] @buffer << @config.set :message, @config.set :full_log, @buffer.join("\n") @config.silently_trigger(:log_message) end |
Instance Method Details
#log(level, message, line_prefix = nil) ⇒ Object
Log and do awesome things I wish there was a nicer way to do this. Hax on device.puts, maybe?
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/capistrano/log_with_awesome.rb', line 23 def log(level, , line_prefix=nil) if level <= self.level indent = "%*s" % [Capistrano::Logger::MAX_LEVEL, "*" * (Capistrano::Logger::MAX_LEVEL - level)] (RUBY_VERSION >= "1.9" ? .lines : ).each do |line| if line_prefix self.class.log_with_awesome "#{indent} [#{line_prefix}] #{line.strip}" else self.class.log_with_awesome "#{indent} #{line.strip}" end end end super(level, , line_prefix) end |