No commit activity in last 3 years
No release in over 3 years
Simple formatter for logging Capistrano tasks
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.6
>= 0

Runtime

~> 1.2
~> 1.3
 Project Readme

Capistrano Simple Formatter

Simple formatter for Capistrano 3.

Installation

With bundler:

gem 'capistrano-simple-formatter'

or without bundler:

$ gem install capistrano-simple-formatter

require 'capistrano-simple-formatter'

Usage

Set the Capistrano format to :simple:

# deploy.rb

set :format, :simple

Adjust the log level as needed:

# deploy.rb

set :log_level, :fatal

Then, within any task block you can access the formatter through SSHKit.config.output, or just output within an on block.

Examples

Hook into Capistrano callbacks:

before('deploy:restart', :log_before_deploy_restart) do
  SSHKit.config.output.start("Restarting apps")
end

after('deploy:restart', :log_after_deploy_restart) do
  SSHKit.config.output.success
end

Log on your tasks:

task(:link_files) do
  on roles(:app) do
    output.start "Linking files in #{host}"
    # Do your work

    if success
      output.success
    else
      output.error 'Something went wrong :('
    end
  end
end

Log nested:

namespace(:delayed_jobs) do
  task(:status) do
    SSHKit.config.output.start("Checking delayed_job status...") do
      on roles(:apps), in: :parallel do
        status = run_delayed_job_command(:status) # Your magic

        if status.match(/delayed_job: no instances running/)
          output.error "Not running in #{host}"
        elsif matches = status.match(/delayed_job: running \[pid (?<pid>\d+)\]/)
          output.success "Running in #{host} with pid #{matches[:pid]}"
        else
          output.info status
        end
      end
    end
  end
end

TODO

  • Output samples
  • Examples file
  • Specs