Module: Capistrano

Defined in:
lib/capistrano/recipes/deploy/scm/perforce.rb,
lib/capistrano/cli.rb,
lib/capistrano/ssh.rb,
lib/capistrano/role.rb,
lib/capistrano/shell.rb,
lib/capistrano/cli/ui.rb,
lib/capistrano/errors.rb,
lib/capistrano/logger.rb,
lib/capistrano/command.rb,
lib/capistrano/version.rb,
lib/capistrano/callback.rb,
lib/capistrano/cli/help.rb,
lib/capistrano/transfer.rb,
lib/capistrano/extensions.rb,
lib/capistrano/cli/execute.rb,
lib/capistrano/cli/options.rb,
lib/capistrano/processable.rb,
lib/capistrano/configuration.rb,
lib/capistrano/task_definition.rb,
lib/capistrano/server_definition.rb,
lib/capistrano/recipes/deploy/scm.rb,
lib/capistrano/configuration/roles.rb,
lib/capistrano/configuration/loading.rb,
lib/capistrano/configuration/servers.rb,
lib/capistrano/recipes/deploy/scm/bzr.rb,
lib/capistrano/recipes/deploy/scm/cvs.rb,
lib/capistrano/recipes/deploy/scm/git.rb,
lib/capistrano/configuration/callbacks.rb,
lib/capistrano/configuration/execution.rb,
lib/capistrano/configuration/variables.rb,
lib/capistrano/recipes/deploy/scm/base.rb,
lib/capistrano/recipes/deploy/scm/none.rb,
lib/capistrano/recipes/deploy/strategy.rb,
lib/capistrano/configuration/alias_task.rb,
lib/capistrano/configuration/namespaces.rb,
lib/capistrano/recipes/deploy/scm/darcs.rb,
lib/capistrano/configuration/connections.rb,
lib/capistrano/recipes/deploy/scm/accurev.rb,
lib/capistrano/recipes/deploy/dependencies.rb,
lib/capistrano/configuration/log_formatters.rb,
lib/capistrano/recipes/deploy/scm/mercurial.rb,
lib/capistrano/recipes/deploy/strategy/base.rb,
lib/capistrano/recipes/deploy/strategy/copy.rb,
lib/capistrano/configuration/actions/inspect.rb,
lib/capistrano/recipes/deploy/scm/subversion.rb,
lib/capistrano/recipes/deploy/strategy/export.rb,
lib/capistrano/recipes/deploy/strategy/remote.rb,
lib/capistrano/recipes/deploy/local_dependency.rb,
lib/capistrano/configuration/actions/invocation.rb,
lib/capistrano/recipes/deploy/remote_dependency.rb,
lib/capistrano/recipes/deploy/strategy/checkout.rb,
lib/capistrano/configuration/actions/file_transfer.rb,
lib/capistrano/recipes/deploy/strategy/remote_cache.rb,
lib/capistrano/recipes/deploy/strategy/unshared_remote_cache.rb

Overview

Add custom log formatters

Passing a hash or a array of hashes with custom log formatters.

Add the following to your deploy.rb or in your ~/.caprc

Example:

capistrano_log_formatters = [
  { :match => /command finished/,       :color => :hide,      :priority => 10, :prepend => "$$$" },
  { :match => /executing command/,      :color => :blue,      :priority => 10, :style => :underscore, :timestamp => true },
  { :match => /^transaction: commit$/,  :color => :magenta,   :priority => 10, :style => :blink },
  { :match => /git/,                    :color => :white,     :priority => 20, :style => :reverse }
]

format_logs capistrano_log_formatters

You can call format_logs multiple times, with either a hash or an array of hashes.

Colors:

:color can have the following values:

  • :hide (hides the row completely)

  • :none

  • :black

  • :red

  • :green

  • :yellow

  • :blue

  • :magenta

  • :cyan

  • :white

Styles:

:style can have the following values:

  • :bright

  • :dim

  • :underscore

  • :blink

  • :reverse

  • :hidden

== Text alterations

:prepend gives static text to be prepended to the output :replace replaces the matched text in the output :timestamp adds the current time before the output

Defined Under Namespace

Modules: Deploy, Processable Classes: CLI, Callback, Command, Configuration, ExtensionProxy, Logger, ProcCallback, RemoteError, Role, SSH, ServerDefinition, Shell, TaskCallback, TaskDefinition, Transfer, Version

Constant Summary collapse

Error =
Class.new(RuntimeError)
CaptureError =
Class.new(Capistrano::Error)
NoSuchTaskError =
Class.new(Capistrano::Error)
NoMatchingServersError =
Class.new(Capistrano::Error)
ConnectionError =
Class.new(Capistrano::RemoteError)
TransferError =
Class.new(Capistrano::RemoteError)
CommandError =
Class.new(Capistrano::RemoteError)
LocalArgumentError =
Class.new(Capistrano::Error)
EXTENSIONS =

Holds the set of registered plugins, keyed by name (where the name is a symbol).

{}

Class Method Summary collapse

Class Method Details

.configuration(*args) ⇒ Object

:nodoc:



53
54
55
56
# File 'lib/capistrano/extensions.rb', line 53

def self.configuration(*args) #:nodoc:
  warn "[DEPRECATION] Capistrano.configuration is deprecated. Use Capistrano::Configuration.instance instead"
  Capistrano::Configuration.instance(*args)
end

.plugin(name, mod) ⇒ Object

Register the given module as a plugin with the given name. It will henceforth be available via a proxy object on Configuration instances, accessible by a method with the given name.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/capistrano/extensions.rb', line 20

def self.plugin(name, mod)
  name = name.to_sym
  return false if EXTENSIONS.has_key?(name)

  methods = Capistrano::Configuration.public_instance_methods +
    Capistrano::Configuration.protected_instance_methods +
    Capistrano::Configuration.private_instance_methods

  if methods.any? { |m| m.to_sym == name }
    raise Capistrano::Error, "registering a plugin named `#{name}' would shadow a method on Capistrano::Configuration with the same name"
  end

  Capistrano::Configuration.class_eval <<-STR, __FILE__, __LINE__+1
    def #{name}
      @__#{name}_proxy ||= Capistrano::ExtensionProxy.new(self, Capistrano::EXTENSIONS[#{name.inspect}])
    end
  STR

  EXTENSIONS[name] = mod
  return true
end

.remove_plugin(name) ⇒ Object

Unregister the plugin with the given name.



43
44
45
46
47
48
49
50
51
# File 'lib/capistrano/extensions.rb', line 43

def self.remove_plugin(name)
  name = name.to_sym
  if EXTENSIONS.delete(name)
    Capistrano::Configuration.send(:remove_method, name)
    return true
  end

  return false
end