Skip to content

Commit

Permalink
Remove docs about assigning an IO to SSHKit.config.output (see capist…
Browse files Browse the repository at this point in the history
  • Loading branch information
robd committed May 6, 2015
1 parent e4e0a1a commit 333a86d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ appear at the top.

* Add your entries below here, remember to credit yourself however you want
to be credited!
* Removed broken support for setting output to an IO (See #243). @robd
* Use `SSHKit.config.output = SSHKit::Formatter::SimpleText.new($stdin)` instead
* Added support for :interaction_handler option on commands. @robd
* Removed partially supported 'trace' log level. @robd
* No longer strip whitespace or newlines in `capture` method on Netssh backend. @robd
Expand Down
30 changes: 24 additions & 6 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,23 +206,41 @@ on hosts do
end
```

## Redirect all output to `/dev/null`
## Change the output formatter

```ruby
SSHKit.config.output = File.open('/dev/null')
# The default format is pretty, which outputs colored text
SSHKit.config.format = :pretty

# Text with no coloring
SSHKit.config.format = :simpletext

# Red / Green dots for each completed step
SSHKit.config.format = :dot

# No output
SSHKit.config.format = :blackhole
```

## Implement a dirt-simple formatter class

```ruby
class MyFormatter < SSHKit::Formatter::Abstract
def write(obj)
case obj.is_a? SSHKit::Command
# Do something here, see the SSHKit::Command documentation
module SSHKit
module Formatter
class MyFormatter < SSHKit::Formatter::Abstract
def write(obj)
case obj.is_a? SSHKit::Command
# Do something here, see the SSHKit::Command documentation
end
end
end
end
end

# If your formatter is defined in the SSHKit::Formatter module configure with the format option:
SSHKit.config.format = :myformatter

# Or configure the output directly
SSHKit.config.output = MyFormatter.new($stdout)
SSHKit.config.output = MyFormatter.new(SSHKit.config.output)
SSHKit.config.output = MyFormatter.new(File.open('log/deploy.log', 'wb'))
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,19 @@ By default, the output format is set to `:pretty`:
SSHKit.config.format = :pretty
```

However, if you prefer minimal output, `:dot` format will simply output red or green dots based on the success or failure of operations.
However, if you prefer non colored text you can use the `:simpletext` formatter. If you want minimal output,
there is also a `:dot` formatter which will simply output red or green dots based on the success or failure of operations.
There is also a `:blackhole` formatter which does not output anything.

To output directly to $stdout without any formatting, you can use:
By default, formatters log to `$stdout`, but they can be constructed on any IO:

```ruby
SSHKit.config.output = $stdout
# output to a StringIO:
out = StringIO.new
SSHKit.config.output = SSHKit::Formatter::Pretty.new(out)

# or output to a file:
SSHKit.config.output = SSHKit::Formatter::SimpleText.new(File.open('log/deploy.log', 'wb'))
```

#### Custom formatters
Expand Down

0 comments on commit 333a86d

Please sign in to comment.